Rasa: module load exception too generic

Created on 6 Nov 2018  路  14Comments  路  Source: RasaHQ/rasa

Rasa NLU version: 0.13.7

Operating system (windows, osx, ...): macOS High Sierra (10.13.4)

Content of model configuration file:

language: en
pipeline:
- name: "path.to.my.EntityRecognizer"
- name: "intent_classifier_sklearn"

Same path was specified in the class itself.

Issue:
I get

Exception: Failed to find component class for 'path.to.my.EntityRecognizer'. Unknown component name. Check your configured pipeline and make sure the mentioned component is not misspelled. If you are creating your own component, make sure it is either listed as part of the `component_classes` in `rasa_nlu.registry.py` or is a proper name of a class in a module.

while running
python -m rasa_nlu.train --config nlu_config.yml --data training_data/ --path ./

This error message is not correct however and is misleading as I could validate that in my case the correct path is actually being picked up by rasa, but this message is being shown because exception catch in line 111 in rasa_nlu.registry is too generic so it picks up other exceptions happening on load of module.

difficulty type type

All 14 comments

Thanks for raising this issue, @wochinge will get back to you about it soon.

@yousrahmoh
I tried it out myself and the class loading form the string works fine.
Can you provide your directory structure, so that I can check whether your path is right?

Note that your current pipeline makes no sense in general, as you first have to apply a featurizer before you can apply all the other components (see the description part of https://rasa.com/docs/nlu/components/#intent-classifier-sklearn)

This issue has been automatically closed because there has been no response to our request for more information from the original author. Without this, we don't have enough information to help you. Please comment below with the requested information if you still need help.

@wochinge
The issue happens when your code has a problem on import of other modules. The issue is emanating from the use of except Exception which is used on line 111 in rasa_nlu.registry. This is generally discouraged in python as the above issue will happen; This exception will fire on behalf of all other failures in your code and the real problem is lost in the misleading error message telling you to double check the path to your custom component. Exceptions need to be more specific.

On your other note, above is just a preview of my pipeline. Full pipeline (which currently works fine) is as follows:

language: en
pipeline:
- name: "nlp_spacy"
- name: "intent_featurizer_spacy"
- name: "harviva.entity.extractor.MyEntityExtractor"
- name: "intent_classifier_sklearn"
- name: "harviva.entity.postprocessor.MyEntityPostProcessor"

@yousrahmoh
I tried it out myself and the class loading form the string works fine.
Can you provide your directory structure, so that I can check whether your path is right?

Note that your current pipeline makes no sense in general, as you first have to apply a featurizer before you can apply all the other components (see the description part of https://rasa.com/docs/nlu/components/#intent-classifier-sklearn)

Seems to me like the more specific exceptions should be KeyError for when file is not found in globals and attribute error in case it's a path. Referring to logic in https://github.com/RasaHQ/rasa_nlu/blob/master/rasa_nlu/utils/__init__.py

@yousrahmoh You are right! I see now what you mean! We will improve this (you are also welcome to contribute a pull request for that 馃檪 )

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.

@erohmensing what? :D can you move it back to maintenance in the sprint board

Hahah sorry I accidentally closed this when I was having sprint board issues 馃槄didn't realize it wouldn't go back to maintenance when i re-opened it!

I want to work on this

Awesome @hsm207 . Let us know if you need feedback / help 馃殌

@wochinge There is no unit test to test this functionality of get_component_class, is there?

@wochinge There is no unit test to test this functionality of get_component_class, is there?

Check out test_components. There are tests (e.g. test_builder_create_by_module_path) which test create_component with custom modules, which then should call the get_component_class

@wochinge I've made PR #4166. Please let me know if I should change something.

Was this page helpful?
0 / 5 - 0 ratings