How to query the lattice execution result#

Firstly, define a workflow using the lattice decorator.

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)

Secondly, dispatch the workflow and retrieve the result using ct.get_result.


Setting the wait variable to True makes sure that the result is retrieved once all the subtask nodes have finished executing.

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.

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