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: require process handlers to be instance methods #3782

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Feb 20, 2020

Fixes #3780

The original implementation of the register_process_handler allowed an
unbound method to be bound to a subclass of BaseRestartWorkChain
outside of its scope. Since this also makes it possible to attach these
process handlers from outside of the module of the work chain, this will
run the risk of the loss of provenance. Here we rename the decorator to
process_handler and it can only be applied to instance methods. This
forces the handlers to be defined in the same module as the work chain
to which they apply.

@sphuber sphuber force-pushed the fix_3780_base_restart_restrict_registering branch 2 times, most recently from b5abd1e to 8f04725 Compare February 20, 2020 23:05
Copy link
Contributor

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

Thanks, @sphuber.

Just a few comments, questions. I did not try to run it myself yet.

aiida/engine/processes/workchains/restart.py Outdated Show resolved Hide resolved
aiida/engine/processes/workchains/restart.py Show resolved Hide resolved
aiida/engine/processes/workchains/restart.py Outdated Show resolved Hide resolved
aiida/engine/processes/workchains/restart.py Show resolved Hide resolved
aiida/engine/processes/workchains/utils.py Show resolved Hide resolved
The original implementation of the `register_process_handler` allowed an
unbound method to be bound to a subclass of `BaseRestartWorkChain`
outside of its scope. Since this also makes it possible to attach these
process handlers from outside of the module of the work chain, this will
run the risk of the loss of provenance. Here we rename the decorator to
`process_handler` and it can only be applied to instance methods. This
forces the handlers to be defined in the same module as the work chain
to which they apply.
@sphuber sphuber force-pushed the fix_3780_base_restart_restrict_registering branch from 8f04725 to ee676c2 Compare February 21, 2020 08:01
@yakutovicha yakutovicha self-requested a review February 21, 2020 08:29
@sphuber sphuber merged commit 617b2df into aiidateam:develop Feb 21, 2020
@sphuber sphuber deleted the fix_3780_base_restart_restrict_registering branch February 21, 2020 09:26
csadorf pushed a commit that referenced this pull request Mar 5, 2020
…ds (#3782)

The original implementation of the `register_process_handler` allowed an
unbound method to be bound to a subclass of `BaseRestartWorkChain`
outside of its scope. Since this also makes it possible to attach these
process handlers from outside of the module of the work chain, this will
run the risk of the loss of provenance. Here we rename the decorator to
`process_handler` and it can only be applied to instance methods. This
forces the handlers to be defined in the same module as the work chain
to which they apply.
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: require process handlers be defined as instance methods
2 participants