How to query electron execution status#
Let us first define a workflow comprised of subtasks. Adding subtasks to workflows is discussed in greater detail in How to add electrons to lattices.
import covalent as ct import time @ct.electron def add(x, y): time.sleep(5) return x + y @ct.electron def multiply(x, y): return x * y @ct.lattice def workflow(x, y): res_1 = add(x=x, y=y) return multiply(x=res_1, y=y)
Then we visualize the plots (described in How to visualize lattices) to find out the node ids for the electrons / subtasks.
dispatch_id = ct.dispatch(workflow)(x=1, y=2)
from IPython import display display.Image("images/query_electron_image.png", height="20pc")
Once the lattice has been constructed and dispatched (as shown below), we can query the status of individual subtask execution status using the node ids from the lattice visualization.
Once workflows have been dispatched to the server and the dispatch ids are stored, the user can then query the results later using
dispatch_id = ct.dispatch(workflow)(x=1, y=2) time.sleep(2) result = ct.get_result(dispatch_id=dispatch_id, wait=False) result.get_node_result(node_id=0)['status']
Once we query the nodes being executed, we have access to the execution status via the
status field which take the values
NEW_OBJECT, if the task has not yet been dispatched).