Skip to content
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

BaseRestartWorkChain: add the get_outputs hook #5618

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Aug 10, 2022

Fixes #5617

The BaseRestartWorkChain, in the results outline step, will take the
outputs of the last completed CalcJob and attach them to the work
chain itself. There are use cases where the implementation may want to
slightly adapt the outputs before attaching them. By abstracting the
code that fetches the outputs to a separate method get_outputs, it
provides a hook for implementations to customize this behavior.

@sphuber sphuber requested a review from mbercx August 10, 2022 14:17
mbercx
mbercx previously approved these changes Aug 10, 2022
Copy link
Member

@mbercx mbercx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @sphuber! Field tested in the context of aiidateam/aiida-quantumespresso#818, and it serves this use case perfectly. But maybe we should still add a bit more explanation on why there is a separate method to get the outputs?

@@ -295,6 +295,10 @@ def inspect_process(self) -> Optional['ExitCode']: # pylint: disable=too-many-b

return None

def get_outputs(self, node) -> Mapping[str, orm.Node]:
"""Return a mapping of the outputs that should be attached as outputs to the work chain."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still add a sentence of two explaining that this method can be overridden in case the BaseRestartWorkChain needs to adjust the outputs of the underlying CalcJob somehow?

@sphuber
Copy link
Contributor Author

sphuber commented Aug 11, 2022

Thanks @mbercx . I have updated the docstring and added some documentation

The `BaseRestartWorkChain`, in the `results` outline step, will take the
outputs of the last completed `CalcJob` and attach them to the work
chain itself. There are use cases where the implementation may want to
slightly adapt the outputs before attaching them. By abstracting the
code that fetches the outputs to a separate method `get_outputs`, it
provides a hook for implementations to customize this behavior.
@sphuber sphuber force-pushed the feature/5617/base-restart-get-results branch from a659314 to 92e874f Compare August 11, 2022 07:56
Copy link
Member

@mbercx mbercx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, sounds clear to me! 👍

@sphuber sphuber merged commit 1407c43 into aiidateam:main Aug 11, 2022
@sphuber sphuber deleted the feature/5617/base-restart-get-results branch August 11, 2022 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BaseRestartWorkChain: add a hook to allow modifying the results that are returned
2 participants