-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Process functions: Allow nested output namespaces (#5954)
Up till now, the following was not possible: @calcfunction def add(x, y): return {'nested.output': x + y} An exception would be raised by `plumpy` because the `nested` output namespace, defined by the `ProcessSpec` that is automatically generated from the function signature, does not contain the port `output`. The automatically generated process spec _does_ mark the outputs namespace as dynamic, but this was not being applied recursively. Not only is this functionality for users, the `Parser.parse_from_node` functonality is currently broken if the `Parser` returns output nodes in nested namespaces. The reason is that the `parse_from_node` creates a `calcfunction` on-the-fly which raises when it gets the outputs with the nested labels. Even though the original `Process` class may have specified these nested output namespaces, the on-the-fly calcfunction to capture the manual re-parsing does not support this. The addition of this functionality requires a change in `plumpy` which was released with `plumpy==0.21.6` which is therefore made the minimum required version. This version also includes another fix where the recently introduced check on the type of the return value of a workchain conditional predicate, was changed from raising an exception, to logging a deprecation warning. The correspondig test is updated to check that the user warning is emitted instead of catching the exception.
- Loading branch information
Showing
10 changed files
with
51 additions
and
14 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
11 changes: 11 additions & 0 deletions
11
docs/source/topics/processes/include/snippets/functions/calcfunction_nested_outputs.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
from aiida.engine import calcfunction | ||
from aiida.orm import Int | ||
|
||
|
||
@calcfunction | ||
def add(alpha, beta): | ||
return {'nested.sum': alpha + beta} | ||
|
||
result = add(Int(1), Int(2)) | ||
assert result['nested']['sum'] == 3 |
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
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
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
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