How to query multiple lattice execution results#
Firstly, we construct and dispatch mutliple workflows.
Tip
Keep track of the dispatch ids in order to be able to retrieve the results at a later time.
[1]:
import covalent as ct
@ct.electron
def identity(x):
return x
@ct.electron
def square(x):
return x * x
@ct.lattice
def workflow(a):
val_1 = identity(x=a)
return square(x=val_1)
params = [1, 2, 3, 4]
dispatch_ids = [ct.dispatch(workflow)(a=param) for param in params]
print(dispatch_ids)
['0fc1a80c-ff5f-4c66-881e-adecad89a955', '4e48fc76-ffd6-4646-ab23-67755638fdf1', 'b6ce761c-9a95-4420-adfc-284d78b260c4', 'fdfac11b-14f4-4b67-ab05-eec8b89233c1']
Lastly, we can query and retrieve the workflow results corresponding to the dispatch ids as follows.
[2]:
results = []
for dispatch_id in dispatch_ids:
result = ct.get_result(dispatch_id=dispatch_id, wait=True)
results.append(result)
Tip
We can also use the print()
method to see the results.
[3]:
print(results[1])
Lattice Result
==============
status: COMPLETED
result: 1
inputs: {'a': 1}
error: None
start_time: 2022-01-23 00:57:20.181555+00:00
end_time: 2022-01-23 00:57:20.223643+00:00
results_dir: /tmp/results
dispatch_id: 0fc1a80c-ff5f-4c66-881e-adecad89a955
Node Outputs
------------
identity(0): 1
:parameter:1(1): 1
square(2): 1
[ ]: