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

def add(x, y):
    return x + y

def multiply(x, y):
    return x * y

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 ct.get_result.

dispatch_id = ct.dispatch(workflow)(x=1, y=2)
result = ct.get_result(dispatch_id=dispatch_id, wait=False)

Once we query the nodes being executed, we have access to the execution status via the status field which take the values RUNNING or COMPLETED (or NEW_OBJECT, if the task has not yet been dispatched).