Qiskit / qiskit-ibmq-provider

Qiskit Provider for accessing the quantum devices and simulators at IBM Quantum.
Apache License 2.0
243 stars 143 forks source link

One of the required arguments is missing if a job has been cancelled due to "ran too long" reason #1177

Closed marekyggdrasil closed 1 year ago

marekyggdrasil commented 1 year ago

Backend: ibmq_jakarta Job id: ci8sq4961rck8jpp4os0 (if relevant)

Description of the bug:

For certain jobs provider fails to retrieve the job. I dig in deeper and found that it happens for jobs that have Cancelled - Ran too long error message.

It happens here: https://github.com/Qiskit/qiskit-ibmq-provider/blob/590f68d9ddb42a45c4ac8a8626ea60da85575b21/qiskit/providers/ibmq/ibmqbackendservice.py#L665

For my job that has Cancelled - Ran too long the status required argument is missing leading to following error

2023-06-21 12:17:16,618 - urllib3.connectionpool - DEBUG - https://api.quantum-computing.ibm.com:443 "GET /api/Network/ibm-q/Groups/open/Projects/main/devices/ibmq_jakarta/queue/status HTTP/1.1" 200 None
2023-06-21 12:17:16,907 - urllib3.connectionpool - DEBUG - https://api.quantum-computing.ibm.com:443 "GET /api/Network/ibm-q/Groups/open/Projects/main/Jobs/ci8sq4961rck8jpp4os0/v/1 HTTP/1.1" 200 None
2023-06-21 12:17:16,910 - root - ERROR - "Unexpected return value received from the server when retrieving job ci8sq4961rck8jpp4os0: __init__() missing 1 required positional argument: 'status'"
Traceback (most recent call last):
  File "/home/donald/.pyenv/versions/3.7.4/envs/antideterminism/lib/python3.7/site-packages/qiskit/providers/ibmq/ibmqbackendservice.py", line 665, in retrieve_job
    job = IBMQJob(backend=backend, api_client=self._provider._api_client, **job_info)
TypeError: __init__() missing 1 required positional argument: 'status'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/donald/.pyenv/versions/3.7.4/envs/antideterminism/lib/python3.7/site-packages/antideterminism/check.py", line 124, in main
    result, new_status = checkJob(ibm_job_id, ibm_backend, token)
  File "/home/donald/.pyenv/versions/3.7.4/envs/antideterminism/lib/python3.7/site-packages/antideterminism/quantum.py", line 78, in checkJob
    job = backend.retrieve_job(ibm_job_id)
  File "/home/donald/.pyenv/versions/3.7.4/envs/antideterminism/lib/python3.7/site-packages/qiskit/providers/ibmq/ibmqbackend.py", line 695, in retrieve_job
    job = self._provider.backend.retrieve_job(job_id)
  File "/home/donald/.pyenv/versions/3.7.4/envs/antideterminism/lib/python3.7/site-packages/qiskit/providers/ibmq/ibmqbackendservice.py", line 669, in retrieve_job
    'when retrieving job {}: {}'.format(job_id, str(ex))) from ex
qiskit.providers.ibmq.exceptions.IBMQBackendApiProtocolError: "Unexpected return value received from the server when retrieving job ci8sq4961rck8jpp4os0: __init__() missing 1 required positional argument: 'status'"

code to reproduce

import qiskit

from qiskit.providers.ibmq.exceptions import IBMQAccountError
from qiskit import IBMQ

backend_name = 'backend name'
job_id = 'job id'
provider = IBMQ.enable_account('your token here')

backend = provider.get_backend(backend_name)
pending_jobs = backend.status().pending_jobs

job = backend.retrieve_job(job_id)

it will crash on the last line. Of course to able to reproduce you need a job that was cancelled due to this specific reason.

kt474 commented 1 year ago

Hi @marekyggdrasil! This repo, qiskit-ibmq-provider has been deprecated - you can retrieve jobs from the "new provider" https://github.com/Qiskit/qiskit-ibm-provider