-
Notifications
You must be signed in to change notification settings - Fork 5
WorkGraph Engine
To know how the WorkGraph engine works, we can compare it with the WorkChain.
WorkChain uses the outline to execute the workflow. Each step in the outline can submit sub-processes and wait until all sub-processes are finished. To be more detailed, it uses the to_context
method to collect the sub-processes (awaitables), and then enter the Waiting
state. Each awaitable has a callback function (_on_awaitable_finished
). So when an awaitable is finished, the runner
will call the callback function to remove the awaitable. If no more awaitable exist, the workchain will resume, and enter the Running
state, and do the next step.
In WorkGraph, when an awaitable is finished, the runner
will call the callback function to remove the awaitable. And, the WorkGraph will resume immediately (without waiting for other awaitables), and enter the Running
state, and do the next step.
AiiDA process will save a checkpoint when entering a new state. So that the runner can re-create a process instance from it. However, the callback will be lost. So when re-creating the instance, one needs to add the awaitable callback again.