Querying Workflow (Lattice) Execution Status in a Notebook
Once you have dispatched a workflow, use the Covalent Result
object to check run status of the lattice programmatically. You can also check the status of individual electrons.
Prerequisites
Define and run a workflow:
import time
import covalent as ct
@ct.electron
def add(x, y):
return x + y
@ct.electron
def multiply(x, y):
time.sleep(5)
return x * y
@ct.lattice
def workflow(x, y):
res_1 = add(x=x, y=y)
return multiply(x=res_1, y=y)
dispatch_id = ct.dispatch(workflow)(x=2, y=3)
Procedure
- Retrieve the
result
object using the dispatch ID with thect.get_result()
function.
To retrieve the result only once the computation is completed, set wait=True
. Otherwise, set wait=False
.
result = ct.get_result(dispatch_id=dispatch_id, wait=False)
- The dispatch status is maintained in the
status
attribute of the result object. While the computations are running, the status isRUNNING
:
print(result.status)
RUNNING
- The result object is updated continuously until the workflow is finished. The final status can be one of several values, including
COMPLETED
,FAILED
, andCANCELED
.
To check the computation status again, re-retrieve the results object:
result = ct.get_result(dispatch_id=dispatch_id, wait=True)
print(result.status)
COMPLETED