Skip to main content

Get Result

cc.get_result

#

Gets the result of a Covalent workflow that has been dispatched to the cloud.

This function retrieves the result of a dispatched Covalent workflow that has been executed on the cloud. The function takes the dispatch ID of the workflow and retrieves the results from the cloud. The result is returned as a Result object that contains the status of the workflow, the final result of the lattice, and any error messages that may have occurred during execution.

Parameters

dispatch_id(str) – The dispatch id assigned to the workflow.

wait(bool) – Controls how long the function waits for the server to return a result. if False, the function will not wait and will return the current status of the workflow. if True, the function will wait for the result to finish and keep retrying until the result is available.

status_only(bool) – If True, only retrieves the status of the workflow and not the full result.

settings – The Covalent settings to use for the request.

Return Type

Result

Returns

A Result object that contains the status of the workflow, the final result of the lattice, and any error messages that may have occurred during execution.

Examples

Use an ID to get the result of a dispatched workflow. Passing wait=True blocks this call while the workflow is still running.

import covalent_cloud as cc

run_id = "3dbdd6bc-bb62-4430-befd-7133d295f71f"
output = cc.get_result(run_id, wait=True)

Some output attributes are lazy-loaded to conserve memory. These attributes can be downloaded using the .load() method.

result = output.result.load()
error = output.error.load()

if error is not None:
print("Error:", error) # Error message
else:
print("Result:", result) # Python object, lattice return value

Output objects also let us inspect specific nodes.

node_id = 12
node_output = output.get_node_result(node_id)
print("node 12 output:", node_output["output"].load()) # Python object, electron return value
print("node 12 error:", node_output["error"].load()) # Error message
print("node 12 stdout:", node_output["stdout"].load())
print("node 12 stderr:", node_output["stderr"].load())

Other, fixed-size output attributes do not require manual downloading.

print("Workflow status:", output.status)
print("Total run duration:", output.end_time - output.start_time)

This also applies for node-specific attributes.

node_output = output.get_node_result(node_id)
print("node 12 electron name:", node_output["node_name"])
print("node 12 status:", node_output["status"])
print("node 12 run duration:", node_output["end_time"] - node_output["start_time"])