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

warn for invalid keys for components #7134

Merged
merged 18 commits into from
Nov 5, 2020
Merged

warn for invalid keys for components #7134

merged 18 commits into from
Nov 5, 2020

Conversation

indam23
Copy link
Contributor

@indam23 indam23 commented Oct 29, 2020

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)

Should this raise InvalidConfigError instead, the way validate_requirements does?

@indam23 indam23 requested a review from wochinge October 29, 2020 15:06
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.

Thanks for taking this over 🙌

@@ -0,0 +1 @@
Added warning for when an option is provided for a component that is not listed as a key in the defaults for that component.
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add the link to the documentation for Components please?

rasa/nlu/components.py Outdated Show resolved Hide resolved

for component in pipeline:
component_name = component.get("name")
component_class = registry.get_component_class(component_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this may raise an exception. Maybe it would be better to run the validation within _build_pipeline?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or even better within component.create_component?

Copy link
Contributor

Choose a reason for hiding this comment

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

that would also avoid having to do the check in two locations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mm I tried moving it into component.create_component, but in that case extra keys are present that aren't allowed for the child class, but are for the base class (e.g. intent_classification is present for ResponseSelector). So, it isn't only checking the user-provided config at that point.

Re. putting it in _build_pipeline - you mean moving the logic inside the function instead of calling it from there? Which exception would that avoid?

Copy link
Contributor

Choose a reason for hiding this comment

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

it would have the advantage that you don't have to load the components yourself in _build_pipeline (which can go wrong and then you'd need error handling).You'd already have the instantiated components in _build_pipeline which should simplify your validations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved it - does that work?

rasa/nlu/components.py Outdated Show resolved Hide resolved
tests/nlu/test_components.py Show resolved Hide resolved
changelog/6966.improvement.md Outdated Show resolved Hide resolved
rasa/nlu/components.py Outdated Show resolved Hide resolved
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.

Couple of smaller suggestions. Please have look. Looks good otherwise 🚀

changelog/6966.improvement.md Outdated Show resolved Hide resolved
rasa/nlu/components.py Outdated Show resolved Hide resolved
rasa/nlu/components.py Outdated Show resolved Hide resolved
rasa/nlu/components.py Outdated Show resolved Hide resolved
rasa/nlu/model.py Outdated Show resolved Hide resolved
tests/nlu/test_components.py Outdated Show resolved Hide resolved
rasa/nlu/components.py Outdated Show resolved Hide resolved
rasa/nlu/model.py Outdated Show resolved Hide resolved
Co-authored-by: Tobias Wochinger <t.wochinger@rasa.com>
@rasabot rasabot merged commit 472f894 into master Nov 5, 2020
@rasabot rasabot deleted the component_keys_check branch November 5, 2020 15:44
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.

Warn for invalid keys for classifiers
3 participants