Parser.parse_from_node
: Validate outputs against process spec
#6159
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
parse_from_node
clasmethod is a utility function to call theparse
method of aParser
implementation for a givenCalcJobNode
. It automatically callsparse
in the correct manner, passing theretrieved
output node, and wrapping it in a calcfunction to optionally store the provenance.However, since the
calcfunction
by default has a dynamic output namespace and so accepts all outputs, it would not perform the same output validation that the originalCalcJob
would have done since that most likely will have defined specific outputs. Especially given that theparse_from_node
method would often be used in unit tests to testParser
implementations, having the output validation be different would make it possible to mis bugs. For example, if the parser assigns an invalid output node, this would go unnoticed.The
parse_from_node
is updated to patch the output specification of thecalcfunction
with that of the process class that was used to created theCalcJobNode
which is being passed as an argument. As long as the process can of course be loaded. This ensures that when thecalcfunction
return the outputs returned byParser.parse
they are validated against the output specification of the originalCalcJob
class. If it fails, aValueError
is raised.