How to query the lattice execution result#
Firstly, define a workflow using the lattice
decorator.
[1]:
import covalent as ct
import time
@ct.electron
def add(x, y):
time.sleep(1)
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)
Secondly, dispatch the workflow and retrieve the result using ct.get_result
.
Note
Setting the wait
variable to True
makes sure that the result is retrieved once all the subtask nodes have finished executing.
[2]:
dispatch_id = ct.dispatch(workflow)(x=2, y=3)
result = ct.get_result(dispatch_id=dispatch_id, wait=True)
The various attributes of the result can be accessed as shown below.
[3]:
print(f"workflow execution status: {result.status}")
print(f"result: {result.result}")
print(f"inputs: {result.inputs}")
print(f"execution start time: {result.start_time}")
print(f"execution end time: {result.end_time}")
workflow execution status: COMPLETED
result: 15
inputs: {'x': 2, 'y': 3}
execution start time: 2022-01-23 00:57:00.966220+00:00
execution end time: 2022-01-23 00:57:02.033366+00:00