PortNamespace: Make dynamic apply recursively#263
Merged
sphuber merged 1 commit intosupport/0.21.xfrom Apr 3, 2023
Merged
Conversation
Collaborator
Author
|
@unkcpz This change is required for aiidateam/aiida-core#5954 So in order to provide the proper context, it may make sense to read through that |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## support/0.21.x #263 +/- ##
===============================================
Coverage 90.82% 90.82%
===============================================
Files 21 21
Lines 2971 2971
===============================================
Hits 2698 2698
Misses 273 273 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 in Codecov by Sentry. |
The `dynamic` attribute of a port namespace indicates whether it should
accept ports that are not explicitly defined. This was mostly used
during validation, when a dictionary of port values was matched against
a given `PortNamespace`.
This was, however, not being applied recursively _and_ only during
validation. For example, given a dynamic portnamespace, validating a
dictionary:
{
'nested': {
'output': 'some_value'
}
}
would pass validation without problems. However, the `Process.out` call
that would actually attempt to attach the output to the process instance
would call:
self.spec().outputs.get_port(namespace_separator.join(namespace))
which would raise, since `get_port` would raise a `ValueError`:
ValueError: port 'output' does not exist in port namespace 'nested'
The problem is that the `nested` namespace is expected, because the top
level namespace was marked as dynamic, however, it itself would not also
be treated as dynamic and so attempting to retrieve `some_value` from
the `nested` namespace, would trigger a `KeyError`.
Here the logic in `PortNamespace.get_port` is updated to check in
advance whether the port exists in the namespace, and if not the case
_and_ the namespace is dynamic, the nested port namespace is created.
The attributes of the new namespace are inherited from its parent
namespace, making the `dynamic` attribute act recursively.
c5e2129 to
5d50128
Compare
sphuber
added a commit
that referenced
this pull request
Apr 20, 2023
The `dynamic` attribute of a port namespace indicates whether it should
accept ports that are not explicitly defined. This was mostly used
during validation, when a dictionary of port values was matched against
a given `PortNamespace`.
This was, however, not being applied recursively _and_ only during
validation. For example, given a dynamic portnamespace, validating a
dictionary:
{
'nested': {
'output': 'some_value'
}
}
would pass validation without problems. However, the `Process.out` call
that would actually attempt to attach the output to the process instance
would call:
self.spec().outputs.get_port(namespace_separator.join(namespace))
which would raise, since `get_port` would raise a `ValueError`:
ValueError: port 'output' does not exist in port namespace 'nested'
The problem is that the `nested` namespace is expected, because the top
level namespace was marked as dynamic, however, it itself would not also
be treated as dynamic and so attempting to retrieve `some_value` from
the `nested` namespace, would trigger a `KeyError`.
Here the logic in `PortNamespace.get_port` is updated to check in
advance whether the port exists in the namespace, and if not the case
_and_ the namespace is dynamic, the nested port namespace is created.
The attributes of the new namespace are inherited from its parent
namespace, making the `dynamic` attribute act recursively.
Cherry-pick: 4c29f44
unkcpz
pushed a commit
to unkcpz/plumpy
that referenced
this pull request
Dec 14, 2024
The `dynamic` attribute of a port namespace indicates whether it should
accept ports that are not explicitly defined. This was mostly used
during validation, when a dictionary of port values was matched against
a given `PortNamespace`.
This was, however, not being applied recursively _and_ only during
validation. For example, given a dynamic portnamespace, validating a
dictionary:
{
'nested': {
'output': 'some_value'
}
}
would pass validation without problems. However, the `Process.out` call
that would actually attempt to attach the output to the process instance
would call:
self.spec().outputs.get_port(namespace_separator.join(namespace))
which would raise, since `get_port` would raise a `ValueError`:
ValueError: port 'output' does not exist in port namespace 'nested'
The problem is that the `nested` namespace is expected, because the top
level namespace was marked as dynamic, however, it itself would not also
be treated as dynamic and so attempting to retrieve `some_value` from
the `nested` namespace, would trigger a `KeyError`.
Here the logic in `PortNamespace.get_port` is updated to check in
advance whether the port exists in the namespace, and if not the case
_and_ the namespace is dynamic, the nested port namespace is created.
The attributes of the new namespace are inherited from its parent
namespace, making the `dynamic` attribute act recursively.
Cherry-pick: 4c29f44
agoscinski
pushed a commit
to agoscinski/plumpy
that referenced
this pull request
Apr 13, 2026
The `dynamic` attribute of a port namespace indicates whether it should
accept ports that are not explicitly defined. This was mostly used
during validation, when a dictionary of port values was matched against
a given `PortNamespace`.
This was, however, not being applied recursively _and_ only during
validation. For example, given a dynamic portnamespace, validating a
dictionary:
{
'nested': {
'output': 'some_value'
}
}
would pass validation without problems. However, the `Process.out` call
that would actually attempt to attach the output to the process instance
would call:
self.spec().outputs.get_port(namespace_separator.join(namespace))
which would raise, since `get_port` would raise a `ValueError`:
ValueError: port 'output' does not exist in port namespace 'nested'
The problem is that the `nested` namespace is expected, because the top
level namespace was marked as dynamic, however, it itself would not also
be treated as dynamic and so attempting to retrieve `some_value` from
the `nested` namespace, would trigger a `KeyError`.
Here the logic in `PortNamespace.get_port` is updated to check in
advance whether the port exists in the namespace, and if not the case
_and_ the namespace is dynamic, the nested port namespace is created.
The attributes of the new namespace are inherited from its parent
namespace, making the `dynamic` attribute act recursively.
Cherry-pick: 4c29f44
agoscinski
pushed a commit
that referenced
this pull request
Apr 13, 2026
The `dynamic` attribute of a port namespace indicates whether it should
accept ports that are not explicitly defined. This was mostly used
during validation, when a dictionary of port values was matched against
a given `PortNamespace`.
This was, however, not being applied recursively _and_ only during
validation. For example, given a dynamic portnamespace, validating a
dictionary:
{
'nested': {
'output': 'some_value'
}
}
would pass validation without problems. However, the `Process.out` call
that would actually attempt to attach the output to the process instance
would call:
self.spec().outputs.get_port(namespace_separator.join(namespace))
which would raise, since `get_port` would raise a `ValueError`:
ValueError: port 'output' does not exist in port namespace 'nested'
The problem is that the `nested` namespace is expected, because the top
level namespace was marked as dynamic, however, it itself would not also
be treated as dynamic and so attempting to retrieve `some_value` from
the `nested` namespace, would trigger a `KeyError`.
Here the logic in `PortNamespace.get_port` is updated to check in
advance whether the port exists in the namespace, and if not the case
_and_ the namespace is dynamic, the nested port namespace is created.
The attributes of the new namespace are inherited from its parent
namespace, making the `dynamic` attribute act recursively.
Cherry-pick: 4c29f44
agoscinski
pushed a commit
that referenced
this pull request
Apr 13, 2026
The `dynamic` attribute of a port namespace indicates whether it should
accept ports that are not explicitly defined. This was mostly used
during validation, when a dictionary of port values was matched against
a given `PortNamespace`.
This was, however, not being applied recursively _and_ only during
validation. For example, given a dynamic portnamespace, validating a
dictionary:
{
'nested': {
'output': 'some_value'
}
}
would pass validation without problems. However, the `Process.out` call
that would actually attempt to attach the output to the process instance
would call:
self.spec().outputs.get_port(namespace_separator.join(namespace))
which would raise, since `get_port` would raise a `ValueError`:
ValueError: port 'output' does not exist in port namespace 'nested'
The problem is that the `nested` namespace is expected, because the top
level namespace was marked as dynamic, however, it itself would not also
be treated as dynamic and so attempting to retrieve `some_value` from
the `nested` namespace, would trigger a `KeyError`.
Here the logic in `PortNamespace.get_port` is updated to check in
advance whether the port exists in the namespace, and if not the case
_and_ the namespace is dynamic, the nested port namespace is created.
The attributes of the new namespace are inherited from its parent
namespace, making the `dynamic` attribute act recursively.
Cherry-pick: 4c29f44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
dynamicattribute of a port namespace indicates whether it should accept ports that are not explicitly defined. This was mostly used during validation, when a dictionary of port values was matched against a givenPortNamespace.This was, however, not being applied recursively and only during validation. For example, given a dynamic portnamespace, validating a dictionary:
would pass validation without problems. However, the
Process.outcall that would actually attempt to attach the output to the process instance would call:which would raise, since
get_portwould raise aValueError:The problem is that the
nestednamespace is expected, because the top level namespace was marked as dynamic, however, it itself would not also be treated as dynamic and so attempting to retrievesome_valuefrom thenestednamespace, would trigger aKeyError.Here the logic in
PortNamespace.get_portis updated to check in advance whether the port exists in the namespace, and if not the case and the namespace is dynamic, the nested port namespace is created. The attributes of the new namespace are inherited from its parent namespace, making thedynamicattribute act recursively.