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

Check for illegal inputs #161

Merged
merged 7 commits into from Sep 11, 2019
Merged

Check for illegal inputs #161

merged 7 commits into from Sep 11, 2019

Conversation

UnDarkle
Copy link
Collaborator

@UnDarkle UnDarkle commented Sep 9, 2019

No description provided.

@AppVeyorBot
Copy link

Build rotest 1.0.1368 failed (commit 09f48688e5 by @UnDarkle)

@AppVeyorBot
Copy link

Build rotest 1.0.1370 failed (commit 4b1d12fa29 by @UnDarkle)

@@ -174,3 +176,15 @@ def validate_inputs(self, extra_inputs=[]):
raise AttributeError("Block %r under %r is missing mandatory "
"inputs %s" %
(self.data.name, self.parent, missing_inputs))

def _is_valid_input(self, parameter_name):
"""Check if the given parameter is a valid inputs for the component.
Copy link
Collaborator

Choose a reason for hiding this comment

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

*input

"""Inject parameters into the component.

Args:
override_previous (bool): whether to override previous value of
the parameters if they were already injected or not.
validate_unknown (bool): check that all the parameters are legal.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer just "all parameters are legal"

"""
# The 'mode' parameter is only relevant to the current hierarchy
setattr(self, 'mode', parameters.pop('mode', self.mode))
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can do self.mode = ...
No?

@@ -430,6 +435,18 @@ def _set_parameters(self, override_previous=True, **parameters):
else:
setattr(self, name, value)

if validate_unknown and not self._is_valid_input(name):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe better naming it validate_unknown_inputs for clearer intentions

Args:
parameter_name (str): parameter name to compare with input names.
"""
pass
Copy link
Collaborator

Choose a reason for hiding this comment

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

Raise NotImplementedError

@AppVeyorBot
Copy link

Build rotest 1.0.1372 failed (commit 43b2a8ce0c by @gregoil)

@gregoil gregoil merged commit f4908d4 into master Sep 11, 2019
@gregoil gregoil deleted the error_on_illegal_input branch September 11, 2019 11:58
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.

None yet

5 participants