QuTech-Delft / quantuminspire

Quantum Inspire SDK
Apache License 2.0
65 stars 27 forks source link

Support Qiskit Backend.jobs() and related attributes #72

Closed jwoehr closed 5 years ago

jwoehr commented 5 years ago

Feature request

Support Qiskit Backend.jobs() and related attributes.

User story

My Qis Job program qasm_job.py can fetch job info using Qiskit Backend.jobs() and related methods.

qasm_job.py supports Quantum Inspire as a provider.

However calls to Backend.jobs() fail as follows:

be_jobs = BACKEND.jobs(limit=JOBS)
AttributeError: 'QuantumInspireBackend' object has no attribute 'jobs'

Where BACKEND is correctly instanced to the Quantum Inspire default Backend and JOBS is instance to an integer.

Acceptance criteria

This snippet from my qasm_job.py with consts/vars correctly instanced works correctly with Qiskit for other providers:

    f_string = "Job {} {}"
    if JOBS:
        PROVIDER = account_fu(TOKEN, URL)
        BACKEND = PROVIDER.get_backend(BACKEND_NAME)
        be_jobs = BACKEND.jobs(limit=JOBS)
        for a_job in be_jobs:
            print(f_string.format(str(a_job.job_id()), str(a_job.status())))
        sys.exit(0)

    elif JOB_ID:
        PROVIDER = account_fu(TOKEN, URL)
        BACKEND = PROVIDER.get_backend(BACKEND_NAME)
        a_job = BACKEND.retrieve_job(JOB_ID)
        print(f_string.format(str(a_job.job_id()), str(a_job.status())))
        sys.exit(0)

    elif JOB_RESULT:
        PROVIDER = account_fu(TOKEN, URL)
        BACKEND = PROVIDER.get_backend(BACKEND_NAME)
        a_job = BACKEND.retrieve_job(JOB_RESULT)
        print(f_string.format(str(a_job.job_id()), str(a_job.status())))
        PP = pprint.PrettyPrinter(indent=4, stream=sys.stdout)
        PP.pprint(a_job.result().to_dict())
        sys.exit(0)
kel85uk commented 5 years ago

@QFer or other members of the QI team will be taking a look at it. Hang tight @jwoehr. :-)

QFer commented 5 years ago

We took a look at the ibmqbackend. A few methods are added to the ibmqbackend that are not in the interface of BaseBackend. You mentioned jobs() and retrieve_job(jobid).

Our backend has a method retrieve_job() with a slightly different signature (job_id is string instead of int). Our api has a method to get all the jobs. api.get_jobs() which returns a list of jobs and a method get_job to get a specific job, given the job id.

Are these sufficient for your usage or is the compliance to the ibmqbackend interface important for you?

jwoehr commented 5 years ago

We took a look at the ibmqbackend. A few methods are added to the ibmqbackend that are not in the interface of BaseBackend.

Ah, right. I had not considered that subtlety.

You mentioned jobs() and retrieve_job(jobid). Our backend has a method retrieve_job() with a slightly different signature (job_id is string instead of int). Our api has a method to get all the jobs. api.get_jobs() which returns a list of jobs and a method get_job to get a specific job, given the job id.

Are these sufficient for your usage or is the compliance to the ibmqbackend interface important for you?

Entirely sufficient. Thank you. Shall I close the issue?