-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Engine: fix bug when caching from process with nested outputs #5538
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Test the caching functionality for a :class:`aiida.engine.processes.process.Process`.""" | ||
from aiida.engine import Process, run | ||
from aiida.manage import enable_caching | ||
from aiida.orm import CalcJobNode, Int | ||
|
||
|
||
class NestedOutputsProcess(Process): | ||
"""Process with dynamic nested output namespace.""" | ||
|
||
_node_class = CalcJobNode | ||
|
||
@classmethod | ||
def define(cls, spec): | ||
super().define(spec) | ||
spec.input('a') | ||
spec.output_namespace('nested', dynamic=True) | ||
|
||
def run(self): | ||
self.out('nested', {'a': self.inputs.a + 2}) | ||
|
||
|
||
def test_caching_nested_output_namespace(): | ||
"""Test that caching from a process with a nested output namespace works.""" | ||
_, node_original = run.get_node(NestedOutputsProcess, a=Int(1)) | ||
assert not node_original.is_created_from_cache | ||
|
||
with enable_caching(): | ||
_, node_clone = run.get_node(NestedOutputsProcess, a=Int(1)) | ||
|
||
assert node_clone.is_created_from_cache | ||
assert node_clone.get_cache_source() == node_original.uuid | ||
|
||
outputs = node_clone.get_outgoing().nested() | ||
assert list(outputs.keys()) == ['nested'] | ||
assert list(outputs['nested'].keys()) == ['a'] | ||
assert isinstance(outputs['nested']['a'], Int) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you maybe want to check here that the structure of the cloned node outputs is as expected?
I guess it's fine, just to be safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the test