-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add the concept of a "lazy" PortNamespace
#121
Conversation
3710be6
to
1a6e8db
Compare
The current design will skip the validation of a `PortNamespace` if it is not required *and* no values are passed for it upon process creation. However, before validation, the inputs are pre-processed. This entails that the input dictionary is mapped onto the input port namespace and any input that is not explicitly specified, but corresponds to a port with a default, has the field populated with said default value. This behavior, however, now makes it impossible to skip the validation of a non-required port namespace by not specifying any inputs, as soon as it contains any port with a default. Even if no inputs are passed, the pre-processing will populate the defaults, which will trigger the validation because the inputs for the namespace are no longer empty. To make it possible to have non-required namespaces, that contain nested ports with default values, optionally validated, we introduce a new port namespace property: `populate_defaults`. If a `PortNamespace` has the `populate_defaults` set to `False` the pre processing will only be triggered if there are explicit inputs defined for it. If this is not the case, the population of defaults is skipped.
1a6e8db
to
1fb6627
Compare
OK @giovannipizzi , the port namespace property has been renamed to |
:param dynamic: boolean, if True, the namespace will accept values even when no explicit port is defined | ||
:param populate_defaults: boolean, if False, the pre-processing step does not populate defaults, also not of any | ||
nested ports, if no value was explicitly specified for this namespace. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just add an explicit note: ".. note: if the port is explicitly specified, this parameter is ignored and the defaults are populated"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is what it says, but maybe I can reword it, so that it more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the docstring. I think it should be clear now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Fixes #117
The current design will skip the validation of a
PortNamespace
if itis not required and no values are passed for it upon process creation.
However, before validation, the inputs are pre-processed. This entails
that the input dictionary is mapped onto the input port namespace and
any input that is not explicitly specified, but corresponds to a port
with a default, has the field populated with said default value.
This behavior, however, now makes it impossible to skip the validation
of a non-required port namespace by not specifying any inputs, as soon
as it contains any port with a default. Even if no inputs are passed,
the pre-processing will populate the defaults, which will trigger the
validation because the inputs for the namespace are no longer empty.
To make it possible to have non-required namespaces, that contain nested
ports with defaul values, optionally validated, we introduce a new port
namespace property: "lazy". If a
PortNamespace
is "lazy" the preprocessing will only be triggered if there are explicit inputs defined
for it. If this is not the case, the population of defaults is skipped.