Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information