The dynamic input_namespace is very useful and commonly used. But what’s the usage of a non-dynamic one?
Does anyone have an example on input_namespace, which is not dynamic? I looked at the docs, but it does not give an example of the usage.
The dynamic input_namespace is very useful and commonly used. But what’s the usage of a non-dynamic one?
Does anyone have an example on input_namespace, which is not dynamic? I looked at the docs, but it does not give an example of the usage.
All namespaces are non-dynamic by default . The top-level inputs is a namespace itself and it is non-dynamic. The benefit is that if a wrong input is provided (for example by accident through a typo or something) a validation error is raised.
Hi @sphuber , thanks for the quick reply! The top-level namespace is non-dynamic; I forgot this. ![]()
The benefit is that if a wrong input is provided (for example by accident through a typo or something) a validation error is raised.
Yes, very clear, thanks!
in the docs, it says:
This is where the
dynamicattribute of thePortNamespacecomes in. By default this is set toFalse, but by setting it toTrue, one indicates that that namespace can take a number of values that is unknown at the time of definition of the specification.
This confuses me. For a non-dynamic Port, the number of values it can take is also unknown, right?
For example, the monitors namespace in Calcjob
spec.input_namespace(
            'monitors',
            valid_type=orm.Dict,
            required=False,
            validator=validate_monitors,
            help='Add monitoring functions that can inspect output files while the job is running and decide to '
            'prematurely terminate the job.',
        )
One can pass any number of monitors into it.
Now, I am also confused about how the top-level namespace validates the inputs. ![]()
This because setting valid_type to a particular value, automatically makes the namespace dynamic:
Not sure if this is part of the aiida-core docs, but may be useful to add if not yet the case.
setting
valid_typeto a particular value, automatically makes the namespace dynamic:
That’s the trick part, and it’s not in the aiida-core docs yet. I made an issue
Thank! It is now clear to me.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.