-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parser.parse_from_node
: Validate outputs against process spec (#6159)
The `parse_from_node` clasmethod is a utility function to call the `parse` method of a `Parser` implementation for a given `CalcJobNode`. It automatically calls `parse` in the correct manner, passing the `retrieved` 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 original `CalcJob` would have done since that most likely will have defined specific outputs. Especially given that the `parse_from_node` method would often be used in unit tests to test `Parser` 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 the `calcfunction` with that of the process class that was used to created the `CalcJobNode` which is being passed as an argument. As long as the process can of course be loaded. This ensures that when the `calcfunction` return the outputs returned by `Parser.parse` they are validated against the output specification of the original `CalcJob` class. If it fails, a `ValueError` is raised.
- Loading branch information
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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