plumpy.workchains module¶
-
plumpy.workchains.
ToContext
¶ alias of
builtins.dict
-
class
plumpy.workchains.
WorkChain
(*args: Any, **kwargs: Any)[source]¶ Bases:
plumpy.mixins.ContextMixin
,plumpy.processes.Process
A WorkChain is a series of instructions carried out with the ability to save state in between.
-
_CONTEXT
= 'CONTEXT'¶
-
_STEPPER_STATE
= 'stepper_state'¶
-
_abc_impl
= <_abc_data object>¶
-
_spec_class
¶ alias of
WorkChainSpec
-
load_instance_state
(saved_state: MutableMapping[str, Any], load_context: plumpy.persistence.LoadSaveContext) → None[source]¶ Load the process from its saved instance state.
- Parameters
saved_state – A bundle to load the state from
load_context – The load context
-
run
() → Any[source]¶ This function will be run when the process is triggered. It should be overridden by a subclass.
-
save_instance_state
(out_state: MutableMapping[str, Any], save_context: Optional[plumpy.persistence.LoadSaveContext]) → None[source]¶ Add the instance state to
out_state
. .. important:The instance state will contain a pointer to the ``ctx``, and so should be deep copied or serialised before persisting.
-
classmethod
spec
() → plumpy.workchains.WorkChainSpec[source]¶
-
to_context
(**kwargs: Union[_asyncio.Future, plumpy.processes.Process]) → None[source]¶ This is a convenience method that provides syntactic sugar, for a user to add multiple intersteps that will assign a certain value to the corresponding key in the context of the workchain
-
-
class
plumpy.workchains.
WorkChainSpec
[source]¶
-
plumpy.workchains.
if_
(condition: Callable[[WorkChain], bool]) → plumpy.workchains._If[source]¶ A conditional that can be used in a workchain outline.
Use as:
if_(cls.conditional)( cls.step1, cls.step2 )
Each step can, of course, also be any valid workchain step e.g. conditional.
- Parameters
condition – The workchain method that will return True or False
-
plumpy.workchains.
return_
= <plumpy.workchains._Return object>¶ A global singleton that contains a Return instruction that allows to exit out of the workchain outline directly with None as exit code To set a specific exit code, call it with the desired exit code
Use as:
if_(cls.conditional)( return_ )
or:
if_(cls.conditional)( return_(EXIT_CODE) )
- Parameters
exit_code – an integer exit code to pass as the return value, None by default
-
plumpy.workchains.
while_
(condition: Callable[[WorkChain], bool]) → plumpy.workchains._While[source]¶ A while loop that can be used in a workchain outline.
Use as:
while_(cls.conditional)( cls.step1, cls.step2 )
Each step can, of course, also be any valid workchain step e.g. conditional.
- Parameters
condition – The workchain method that will return True or False