Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept pathlib model path #4341

Closed
Batalex opened this issue Aug 28, 2019 · 5 comments
Closed

Accept pathlib model path #4341

Batalex opened this issue Aug 28, 2019 · 5 comments
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR

Comments

@Batalex
Copy link

Batalex commented Aug 28, 2019

Description of Problem:
I am fond of pathlib and of this particular snippet to load the newest model I have:

import pathlib

from rasa.core.agent import Agent

models_folder = pathlib.Path("models")
latest_model = max(models_folder.glob("*.tar.gz"), key=lambda p: p.stat().st_ctime)

agent = Agent.load(str(latest_model))

The only friction here is str(latest_model). Adding support for pathlib paths would be quite convenient.

Overview of the Solution:

Since os.path functions are compatible with pathlib, the only change we would need to do is right there https://github.com/RasaHQ/rasa/blob/master/rasa/core/agent.py#L355:

model_path = get_model(str(model_path))

I could submit a PR if the feedback is positive.
The interrogation left would be about the type hints: model_path is a Text right now, would a Union[Text, Path] type be acceptable?

@Batalex Batalex added the type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR label Aug 28, 2019
@sara-tagger
Copy link
Collaborator

Thanks for submitting this feature request 🚀@JustinaPetr will get back to you about it soon!✨

@stale
Copy link

stale bot commented Feb 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status:stale label Feb 3, 2020
@tmbo tmbo added area:rasa-oss 🎡 Anything related to the open source Rasa framework good first issue and removed status:stale labels Feb 3, 2020
@silvasara
Copy link
Contributor

silvasara commented Sep 23, 2020

Hi, @Henrike100 and I are interested in taking this issue and will start working on it.

@JustinaPetr
Copy link
Contributor

That's great @silvasara. Please let us know if you need any help with this.

@Batalex
Copy link
Author

Batalex commented Nov 24, 2020

Thanks @silvasara and @Henrike100, it works like a charm 👍
I am closing the issue.

@Batalex Batalex closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR
Projects
None yet
Development

No branches or pull requests

6 participants