You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following fails in the most recent version, whereas it used to work:
In [1]: ns=PortNamespace()
---------------------------------------------------------------------------NameErrorTraceback (mostrecentcalllast)
<ipython-input-1-2b2df46c459f>in<cellline: 1>()
---->1ns=PortNamespace()
NameError: name'PortNamespace'isnotdefinedIn [2]: fromplumpy.portsimportPortNamespaceIn [3]: ns=PortNamespace()
In [4]: ns.valid_type=dictIn [5]: ns.validate({'a': {'b': 1}, 'b': {'test': 'string'}})
Out[5]: plumpy.ports.PortValidationError("Error occurred validating port '.a..b': Invalid type <class 'int'> for dynamic port value: expected <class 'dict'>")
The reason is that if a value is encountered in a port namespace that is dynamic, the code assumes it is another nested namespace, as opposed to a "leaf" value that just happens to have type dict.
There are valid usecases where one would want to define a dynamic namespace that takes any number of dictionaries but that is currently not supported. It would be great if this could also be supported.
It is not clear if this use case can be supported at the same time of supporting arbitrarily nested portnamespaces which is currently the case. It seems impossible for the code to be able to distinguish dictionaries that are intended to be a leaf value or a nested namespace.
Maybe if valid_type=dict is explicitly defined, we can assume the namespace to be "shallow" and every value is considered to be a leaf value.
The text was updated successfully, but these errors were encountered:
The following fails in the most recent version, whereas it used to work:
The reason is that if a value is encountered in a port namespace that is dynamic, the code assumes it is another nested namespace, as opposed to a "leaf" value that just happens to have type
dict
.There are valid usecases where one would want to define a dynamic namespace that takes any number of dictionaries but that is currently not supported. It would be great if this could also be supported.
It is not clear if this use case can be supported at the same time of supporting arbitrarily nested portnamespaces which is currently the case. It seems impossible for the code to be able to distinguish dictionaries that are intended to be a leaf value or a nested namespace.
Maybe if
valid_type=dict
is explicitly defined, we can assume the namespace to be "shallow" and every value is considered to be a leaf value.The text was updated successfully, but these errors were encountered: