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

PortNamespace: Fix bug in valid type checking of dynamic namespaces #255

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

sphuber
Copy link
Collaborator

@sphuber sphuber commented Nov 30, 2022

If a valid_type is set on a PortNamespace it is automatically made dynamic. If a namespace is dynamic, it means that it should accept any nested namespace, however deeply nested. However, the leafs of the inputs should still respect the valid_type. This was not the case though. As soon as a port namespace was made dynamic, any nested input namespace would be expected, regardless of the types of the leaf values.

The PortNamespace.validate_dynamic_ports is made recursive. If a port value is a dictionary, it recursively calls itself to validate its nested values, ultimately making sure that leaf values have a valid type if one is specified for the namespace.

If a `valid_type` is set on a `PortNamespace` it is automatically made
dynamic. If a namespace is dynamic, it means that it should accept any
nested namespace, however deeply nested. However, the leafs of the
inputs should still respect the `valid_type`. This was not the case
though. As soon as a port namespace was made dynamic, any nested input
namespace would be expected, regardless of the types of the leaf values.

The `PortNamespace.validate_dynamic_ports` is made recursive. If a port
value is a dictionary, it recursively calls itself to validate its
nested values, ultimately making sure that leaf values have a valid
type if one is specified for the namespace.
@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Base: 90.73% // Head: 90.74% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (caf0bce) compared to base (ed1b6cb).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@                Coverage Diff                 @@
##           support/0.21.x     #255      +/-   ##
==================================================
+ Coverage           90.73%   90.74%   +0.01%     
==================================================
  Files                  21       21              
  Lines                2964     2967       +3     
==================================================
+ Hits                 2689     2692       +3     
  Misses                275      275              
Impacted Files Coverage Δ
src/plumpy/ports.py 93.38% <100.00%> (+0.07%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sphuber sphuber requested a review from muhrin December 7, 2022 11:14
Copy link
Collaborator

@muhrin muhrin left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@sphuber sphuber merged commit 9fb5f1c into support/0.21.x Dec 7, 2022
@sphuber sphuber deleted the fix/dynamic-port-namespace branch December 7, 2022 16:34
sphuber added a commit that referenced this pull request Dec 7, 2022
…#255)

If a `valid_type` is set on a `PortNamespace` it is automatically made
dynamic. If a namespace is dynamic, it means that it should accept any
nested namespace, however deeply nested. However, the leafs of the
inputs should still respect the `valid_type`. This was not the case
though. As soon as a port namespace was made dynamic, any nested input
namespace would be expected, regardless of the types of the leaf values.

The `PortNamespace.validate_dynamic_ports` is made recursive. If a port
value is a dictionary, it recursively calls itself to validate its
nested values, ultimately making sure that leaf values have a valid
type if one is specified for the namespace.

Cherry-pick: 9fb5f1c
sphuber added a commit that referenced this pull request Dec 7, 2022
…#255)

If a `valid_type` is set on a `PortNamespace` it is automatically made
dynamic. If a namespace is dynamic, it means that it should accept any
nested namespace, however deeply nested. However, the leafs of the
inputs should still respect the `valid_type`. This was not the case
though. As soon as a port namespace was made dynamic, any nested input
namespace would be expected, regardless of the types of the leaf values.

The `PortNamespace.validate_dynamic_ports` is made recursive. If a port
value is a dictionary, it recursively calls itself to validate its
nested values, ultimately making sure that leaf values have a valid
type if one is specified for the namespace.

Cherry-pick: 9fb5f1c
unkcpz pushed a commit to unkcpz/plumpy that referenced this pull request Dec 14, 2024
…aiidateam#255)

If a `valid_type` is set on a `PortNamespace` it is automatically made
dynamic. If a namespace is dynamic, it means that it should accept any
nested namespace, however deeply nested. However, the leafs of the
inputs should still respect the `valid_type`. This was not the case
though. As soon as a port namespace was made dynamic, any nested input
namespace would be expected, regardless of the types of the leaf values.

The `PortNamespace.validate_dynamic_ports` is made recursive. If a port
value is a dictionary, it recursively calls itself to validate its
nested values, ultimately making sure that leaf values have a valid
type if one is specified for the namespace.

Cherry-pick: 9fb5f1c
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.

2 participants