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

fix the "loading model" message which was logged twice #8278

Merged
merged 5 commits into from
Apr 6, 2021
Merged

Conversation

ancalita
Copy link
Member

Proposed changes:

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

@CLAassistant
Copy link

CLAassistant commented Mar 23, 2021

CLA assistant check
All committers have signed the CLA.

@sara-tagger
Copy link
Collaborator

Thanks for submitting a pull request 🚀 @erohmensing will take a look at it as soon as possible ✨

@erohmensing
Copy link
Contributor

Oops, this was the ignore list i was meant to add you to 🙈

@erohmensing erohmensing removed their request for review March 23, 2021 13:02
…a run.

change formatting

fix model path return
rasa/model.py Outdated
def get_model(model_path: Text = DEFAULT_MODELS_PATH) -> TempDirectoryPath:
"""Get a model and unpack it. Raises a `ModelNotFound` exception if
no model could be found at the provided path.
def verify_model_path(model_path: Text = DEFAULT_MODELS_PATH) -> Text:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your clean and precise change 💯

One thing:
I find the naming verify_model_path a little bit confusing as this function is doing two things: verifying the path and also returning the path. How about naming it get_local_model?

"""Get a model and unpack it. Raises a `ModelNotFound` exception if
no model could be found at the provided path.
def verify_model_path(model_path: Text = DEFAULT_MODELS_PATH) -> Text:
"""Verifies that a model path exists.

Args:
model_path: Path to the zipped model. If it's a directory, the latest
trained model is returned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also document the Returns part (pydocstyle unfortunately has a bug which doesn't flag missing Returns 😬 )

@@ -78,6 +79,12 @@ def test_get_model_context_manager(trained_rasa_model: str):
assert not os.path.exists(unpacked)


@pytest.mark.parametrize("model_path", ["foobar", "rasa", "README.md", None])
def test_verify_model_path_exception(model_path: Optional[Text]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you write this test then you probably also want one which checks with valid model files, don't you?

rasa/cli/run.py Outdated
@@ -94,7 +94,7 @@ def run(args: argparse.Namespace):
# make sure either a model server, a remote storage, or a local model is
# configured

from rasa.model import get_model
from rasa.model import verify_model_path, get_model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small note: Our Python guide line states that we rather import the modules instead of the functions directly. This makes it a little bit easier to see where a function is coming from when reading the code.

Copy link
Contributor

@wochinge wochinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some smaller comments, but change is otherwise ready to 💯

rasa/model.py Outdated


def get_model(model_path: Text = DEFAULT_MODELS_PATH) -> TempDirectoryPath:
"""Get a model and unpack it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Get a model and unpack it.
"""Gets a model and unpack it.

rasa/model.py Outdated

Args:
model_path: Path to the zipped model. If it's a directory, the latest
trained model is returned.

Returns:
Path to the unpacked model.
model_path: Path to the zipped model. If it's a directory, the latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
model_path: Path to the zipped model. If it's a directory, the latest
Path to the zipped model. If it's a directory, the latest

rasa/model.py Outdated
"""Get a model and unpack it. Raises a `ModelNotFound` exception if
no model could be found at the provided path.
def get_local_model(model_path: Text = DEFAULT_MODELS_PATH) -> Text:
"""Verifies that a model path exists.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to adapt that one, too. How about:

Suggested change
"""Verifies that a model path exists.
"""Returns verified path to local model archive.

@@ -42,6 +42,7 @@
can_finetune,
create_package_rasa,
get_latest_model,
get_local_model,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor thing: Could we please also import the things by their module here instead of importing the functions directly?

@ancalita ancalita requested a review from joejuzl March 29, 2021 09:57
Copy link
Contributor

@joejuzl joejuzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Although there seems to be a binary file called "other" added.

@ancalita ancalita merged commit f598e6c into 2.4.x Apr 6, 2021
@ancalita ancalita deleted the bug-7260 branch April 6, 2021 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Loading model" is logged twice on rasa run
6 participants