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 method to enable/disable process handlers #3786

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Feb 21, 2020

Fixes #3773

The process_handler decorator is updated with a new keyword argument
enabled which is by default True. By setting it to False the
process handler is disabled and will always be skipped during the
inspect_process outline step. This default can be overridden on a per
instance basis through a new input called handler_overrides.

The base spec of BaseRestartWorkChain defines this new base input
called handler_overrides which takes a mapping of process handler
names to a boolean. For True the process handler is enabled and for
False it is disabled, where disabled means that during the
inspect_process call it is not called but skipped. The validator on
the port ensures that the keys correspond to actual instance methods of
the work chain that are decorated with process_handler. The value
specified in handler_overrides, as the name suggests, override the
default value specified in the decorator.

@yakutovicha
Copy link
Contributor

Thanks, @sphuber, I will test it in lsmo-epfl/aiida-raspa#56 and will let you know.

@sphuber sphuber requested review from greschd and removed request for JPchico February 21, 2020 18:37
The `process_handler` decorator is updated with a new keyword argument
`enabled` which is by default `True`. By setting it to `False` the
process handler is disabled and will always be skipped during the
`inspect_process` outline step. This default can be overridden on a per
instance basis through a new input called `handler_overrides`.

The base spec of `BaseRestartWorkChain` defines this new base input
called `handler_overrides` which takes a mapping of process handler
names to a boolean. For `True` the process handler is enabled and for
`False` it is disabled, where disabled means that during the
`inspect_process` call it is not called but skipped. The validator on
the port ensures that the keys correspond to actual instance methods of
the work chain that are decorated with `process_handler`. The value
specified in `handler_overrides`, as the name suggests, override the
default value specified in the decorator.
@sphuber sphuber force-pushed the fix_3773_base_restart_enable_disable branch from e8c5b9f to 2789ea9 Compare February 24, 2020 17:31
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 a lot, @sphuber. I tested the updated functionality of the base restart work chain on aiida-raspa work chains and everything seems to work without a problem. In particular, I tested disabling/enabling handlers that are enabled/disabled by default and get_process_handlers() function (see my note below).

aiida/engine/processes/workchains/restart.py Show resolved Hide resolved
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.

Great stuff!

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 enable/disable handlers input port
2 participants