Repository: RasaHQ/rasa
Pull request: 3.0 mitie nlp error message
closes #10140

Adds a separate error message to clarify when configuration for MITIE NLU component is incorrect due to a missing file.



Problem statement:
Unclear error message when mitie model does not exist on path
When a model is provided for `MitieNLP` but doesn't exist on disk
e.g.
```yml
pipeline:
  - name: MitieNLP
    model: "data/total_word_feature_extractor.dat"
```
but no `"data/total_word_feature_extractor.dat"`

This is the error:
```
InvalidConfigException: The MITIE component 'MitieNLP' needs the configuration value for 'model'.Please take a look at the documentation in the pipeline section to get more info about this parameter.
```
 However this makes it seem like the parameter is not provided which is confusing. We should have a different message if the file does not exist.

Hints from issue discussion:

Commit message: Update mitie_utils.py

Patch to review:
diff --git a/rasa/nlu/utils/mitie_utils.py b/rasa/nlu/utils/mitie_utils.py
index a2451ac5d3aa..1ce382147fc2 100644
--- a/rasa/nlu/utils/mitie_utils.py
+++ b/rasa/nlu/utils/mitie_utils.py
@@ -86,7 +86,7 @@ def create(
         import mitie
 
         model_file = config.get("model")
-        if not model_file or not Path(model_file).is_file():
+        if not model_file:
             raise InvalidConfigException(
                 "The MITIE component 'MitieNLP' needs "
                 "the configuration value for 'model'."
@@ -95,6 +95,13 @@ def create(
                 "to get more info about this "
                 "parameter."
             )
+        if not Path(model_file).is_file():
+            raise InvalidConfigException(
+                "The model file configured in the MITIE "
+                "component cannot be found. "
+                "Please ensure the directory path and/or "
+                "filename, '{}', are correct.".format(Path(model_file))
+            )
         extractor = mitie.total_word_feature_extractor(str(model_file))
 
         return cls(Path(model_file), extractor)


Code review comments:
diff_hunk: @@ -95,6 +95,13 @@ def create(
                 "to get more info about this "
                 "parameter."
             )
+        if not Path(model_file).is_file():
+            raise InvalidConfigException(
+                "The model file configured in the MITIE "
+                "component cannot be found. "
+                "Please ensure the directory path and/or "
+                "filename, '{}', are correct.".format(Path(model_file))
path: rasa/nlu/utils/mitie_utils.py
text: @user1:
Is it better to use `model_file` for error message instead of a Path object?