aiida.engine.processes.workchains package¶
Module for the WorkChain process and related utilities.
-
aiida.engine.processes.workchains.
ToContext
¶ alias of
__builtin__.dict
-
aiida.engine.processes.workchains.
assign_
(target)[source]¶ Convenience function that will construct an Awaitable for a given class instance with the context action set to ASSIGN. When the awaitable target is completed it will be assigned to the context for a key that is to be defined later
Parameters: target – an instance of a Process or Awaitable Returns: the awaitable Return type: Awaitable
-
aiida.engine.processes.workchains.
append_
(target)[source]¶ Convenience function that will construct an Awaitable for a given class instance with the context action set to APPEND. When the awaitable target is completed it will be appended to a list in the context for a key that is to be defined later
Parameters: target – an instance of a Process or Awaitable Returns: the awaitable Return type: Awaitable
-
class
aiida.engine.processes.workchains.
WorkChain
(inputs=None, logger=None, runner=None, enable_persistence=True)[source]¶ Bases:
aiida.engine.processes.process.Process
A WorkChain, the base class for AiiDA workflows.
-
_CONTEXT
= 'CONTEXT'¶
-
_Process__called
= True¶
-
_STEPPER_STATE
= 'stepper_state'¶
-
__abstractmethods__
= frozenset([])¶
-
__init__
(inputs=None, logger=None, runner=None, enable_persistence=True)[source]¶ Construct the instance only if it is a sub class of WorkChain otherwise raise InvalidOperation.
-
__module__
= 'aiida.engine.processes.workchains.workchain'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_auto_persist
= set(['_CREATION_TIME', '_awaitables', '_enable_persistence', '_future', '_parent_pid', '_paused', '_pid', '_pre_paused_status', '_status'])¶
-
_do_step
()[source]¶ Execute the next step in the outline and return the result.
If the stepper returns a non-finished status and the return value is of type ToContext, the contents of the ToContext container will be turned into awaitables if necessary. If any awaitables were created, the process will enter in the Wait state, otherwise it will go to Continue. When the stepper returns that it is done, the stepper result will be converted to None and returned, unless it is an integer or instance of ExitCode.
-
_node_class
¶ alias of
aiida.orm.nodes.process.workflow.workchain.WorkChainNode
-
_spec
= <aiida.engine.processes.workchains.workchain.WorkChainSpec object>¶
-
_spec_type
¶ alias of
WorkChainSpec
-
_store_nodes
(data)[source]¶ Recurse through a data structure and store any unstored nodes that are found along the way
Parameters: data – a data structure potentially containing unstored nodes
-
action_awaitables
()[source]¶ Handle the awaitables that are currently registered with the workchain
Depending on the class type of the awaitable’s target a different callback function will be bound with the awaitable and the runner will be asked to call it when the target is completed
-
ctx
¶
-
insert_awaitable
(awaitable)[source]¶ Insert a awaitable that will cause the workchain to wait until the wait on is finished before continuing to the next step.
Parameters: awaitable ( aiida.engine.processes.workchains.awaitable.Awaitable
) – The thing to await
-
on_exiting
()[source]¶ Ensure that any unstored nodes in the context are stored, before the state is exited
After the state is exited the next state will be entered and if persistence is enabled, a checkpoint will be saved. If the context contains unstored nodes, the serialization necessary for checkpointing will fail.
-
on_process_finished
(awaitable, pk)[source]¶ Callback function called by the runner when the process instance identified by pk is completed. The awaitable will be effectuated on the context of the workchain and removed from the internal list. If all awaitables have been dealt with, the workchain process is resumed
Parameters: - awaitable – an Awaitable instance
- pk – the pk of the awaitable’s target
-
remove_awaitable
(awaitable)[source]¶ Remove a awaitable.
Precondition: must be a awaitable that was previously inserted
Parameters: awaitable – The awaitable to remove
-
-
aiida.engine.processes.workchains.
if_
(condition)[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
-
aiida.engine.processes.workchains.
while_
(condition)[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
Submodules¶
Enums and function for the awaitables of Processes.
-
class
aiida.engine.processes.workchains.awaitable.
Awaitable
(**kwargs)[source]¶ Bases:
plumpy.utils.AttributesDict
An attribute dictionary that represents an action that a Process could be waiting for to finish.
-
__module__
= 'aiida.engine.processes.workchains.awaitable'¶
-
-
class
aiida.engine.processes.workchains.awaitable.
AwaitableTarget
[source]¶ Bases:
enum.Enum
Enum that describes the class of the target a given awaitable.
-
PROCESS
= 'process'¶
-
__module__
= 'aiida.engine.processes.workchains.awaitable'¶
-
-
class
aiida.engine.processes.workchains.awaitable.
AwaitableAction
[source]¶ Bases:
enum.Enum
Enum that describes the action to be taken for a given awaitable.
-
APPEND
= 'append'¶
-
ASSIGN
= 'assign'¶
-
__module__
= 'aiida.engine.processes.workchains.awaitable'¶
-
-
aiida.engine.processes.workchains.awaitable.
construct_awaitable
(target)[source]¶ Construct an instance of the Awaitable class that will contain the information related to the action to be taken with respect to the context once the awaitable object is completed.
The awaitable is a simple dictionary with the following keys
- pk: the pk of the node that is being waited on
- action: the context action to be performed upon completion
- outputs: a boolean that toggles whether the node itself
Currently the only awaitable classes are ProcessNode and Workflow The only awaitable actions are the Assign and Append operators
Convenience functions to add awaitables to the Context of a WorkChain.
-
aiida.engine.processes.workchains.context.
ToContext
¶ alias of
__builtin__.dict
-
aiida.engine.processes.workchains.context.
assign_
(target)[source]¶ Convenience function that will construct an Awaitable for a given class instance with the context action set to ASSIGN. When the awaitable target is completed it will be assigned to the context for a key that is to be defined later
Parameters: target – an instance of a Process or Awaitable Returns: the awaitable Return type: Awaitable
-
aiida.engine.processes.workchains.context.
append_
(target)[source]¶ Convenience function that will construct an Awaitable for a given class instance with the context action set to APPEND. When the awaitable target is completed it will be appended to a list in the context for a key that is to be defined later
Parameters: target – an instance of a Process or Awaitable Returns: the awaitable Return type: Awaitable
Components for the WorkChain concept of the workflow engine.
-
class
aiida.engine.processes.workchains.workchain.
WorkChain
(inputs=None, logger=None, runner=None, enable_persistence=True)[source]¶ Bases:
aiida.engine.processes.process.Process
A WorkChain, the base class for AiiDA workflows.
-
_CONTEXT
= 'CONTEXT'¶
-
_Process__called
= True¶
-
_STEPPER_STATE
= 'stepper_state'¶
-
__abstractmethods__
= frozenset([])¶
-
__init__
(inputs=None, logger=None, runner=None, enable_persistence=True)[source]¶ Construct the instance only if it is a sub class of WorkChain otherwise raise InvalidOperation.
-
__module__
= 'aiida.engine.processes.workchains.workchain'¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 102¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_auto_persist
= set(['_CREATION_TIME', '_awaitables', '_enable_persistence', '_future', '_parent_pid', '_paused', '_pid', '_pre_paused_status', '_status'])¶
-
_do_step
()[source]¶ Execute the next step in the outline and return the result.
If the stepper returns a non-finished status and the return value is of type ToContext, the contents of the ToContext container will be turned into awaitables if necessary. If any awaitables were created, the process will enter in the Wait state, otherwise it will go to Continue. When the stepper returns that it is done, the stepper result will be converted to None and returned, unless it is an integer or instance of ExitCode.
-
_node_class
¶ alias of
aiida.orm.nodes.process.workflow.workchain.WorkChainNode
-
_spec
= <aiida.engine.processes.workchains.workchain.WorkChainSpec object>¶
-
_spec_type
¶ alias of
WorkChainSpec
-
_store_nodes
(data)[source]¶ Recurse through a data structure and store any unstored nodes that are found along the way
Parameters: data – a data structure potentially containing unstored nodes
-
action_awaitables
()[source]¶ Handle the awaitables that are currently registered with the workchain
Depending on the class type of the awaitable’s target a different callback function will be bound with the awaitable and the runner will be asked to call it when the target is completed
-
ctx
¶
-
insert_awaitable
(awaitable)[source]¶ Insert a awaitable that will cause the workchain to wait until the wait on is finished before continuing to the next step.
Parameters: awaitable ( aiida.engine.processes.workchains.awaitable.Awaitable
) – The thing to await
-
on_exiting
()[source]¶ Ensure that any unstored nodes in the context are stored, before the state is exited
After the state is exited the next state will be entered and if persistence is enabled, a checkpoint will be saved. If the context contains unstored nodes, the serialization necessary for checkpointing will fail.
-
on_process_finished
(awaitable, pk)[source]¶ Callback function called by the runner when the process instance identified by pk is completed. The awaitable will be effectuated on the context of the workchain and removed from the internal list. If all awaitables have been dealt with, the workchain process is resumed
Parameters: - awaitable – an Awaitable instance
- pk – the pk of the awaitable’s target
-
remove_awaitable
(awaitable)[source]¶ Remove a awaitable.
Precondition: must be a awaitable that was previously inserted
Parameters: awaitable – The awaitable to remove
-
-
aiida.engine.processes.workchains.workchain.
if_
(condition)[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
-
aiida.engine.processes.workchains.workchain.
while_
(condition)[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