Skip to content

Provide guidance or ergonomics around "fetch results" retries #1853

Description

@jselig-rigetti

qc.run calls can fail due to a connection timeout when jobs are stuck in the queue for a while.
As is there's no retries to fetch results, so the execution is abandoned because the results can't be re-fetched.

You can get around this today by splitting the qc.run call into separate qc.qam.{execute,get_result} calls, but it probably makes sense to build some ergonomics in to pyquil itself to automatically retry.

Note that qcs-sdk should probably also use get_controller_job_status when awaiting a long-queued jobs, perhaps to periodically print "still queued..." so that the user knows what's going on.

job_id = qc.qam.execute(exe)

while True:
    try:
        # this can be retried on timeout - but not on 404
        result = qc.qam.get_result(job_id)
        break
    except Exception as e:
        if "tcp connect error" in str(e):
            print(f"Timeout retrieving job {job_id} result, retrying...")
            continue
        raise e
            
# use results typically --- 
print(result.get_register_map()["ro"])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions