Querying the Result of a Workflow (Lattice)
Use the dispatch ID to locate and view the result from a previously completed workflow. Print individual attributes of the result.
Prerequisites
Define and dispatch a lattice:
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)
dispatch_id = ct.dispatch(workflow)(x=2, y=3)
- Retrieve the dispatch result object using
ct.get_result
. Set thewait
parameter toTrue
so that the Covalent server waits until the dispatch finishes before retrieving the result.
result = ct.get_result(dispatch_id=dispatch_id, wait=True)
- Print the attributes of the result object that you are interested in.
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: {'args': [], 'kwargs': {'x': <covalent.TransportableObject object at 0x1060ae520>, 'y': <covalent.TransportableObject object at 0x1060ae850>}}
Execution start time: 2023-02-01 19:56:16.391500
Execution end time: 2023-02-01 19:56:17.563476