Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Error in retrieving a job using provider.backend.retrieve_job() #528

Closed
KangHaiYue opened this issue Feb 28, 2023 · 4 comments
Closed

Error in retrieving a job using provider.backend.retrieve_job() #528

KangHaiYue opened this issue Feb 28, 2023 · 4 comments
Labels
type: bug Something isn't working
Milestone

Comments

@KangHaiYue
Copy link

KangHaiYue commented Feb 28, 2023

Information

  • qiskit-ibm-provider 0.3.0:
  • Python version 3.8.3:
  • Operating system Win10 Pro:

What is the current behavior?

On the jupyter notebook, when retrieving a job from a dynamic circuit, following error pops up:


TypeError Traceback (most recent call last)
in
10
11
---> 12 job = provider.backend.retrieve_job('cfu4j33mcdu7bt2gj250')
13
14

~\anaconda3\lib\site-packages\qiskit_ibm_provider\ibm_backend_service.py in retrieve_job(self, job_id)
591 job_info = self._default_hgp._api_client.job_get(job_id)
592 else:
--> 593 job_info = self._provider._runtime_client.job_get(job_id)
594 if job_info.get("program", {}).get("id") not in [
595 "circuit-runner",

~\anaconda3\lib\site-packages\qiskit_ibm_provider\api\clients\runtime.py in job_get(self, job_id)
157 JSON response.
158 """
--> 159 response = self._api.program_job(job_id).get()
160 logger.debug("Runtime job get response: %s", response)
161 return response

~\anaconda3\lib\site-packages\qiskit_ibm_provider\api\rest\program_job.py in get(self)
54 JSON response.
55 """
---> 56 return self.session.get(self.get_url("self")).json(cls=RuntimeDecoder)
57
58 def job_type(self) -> str:

~\anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs)
896 # used.
897 pass
--> 898 return complexjson.loads(self.text, **kwargs)
899
900 @Property

~\anaconda3\lib\site-packages\simplejson_init_.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)
540 raise TypeError("use_decimal=True implies parse_float=Decimal")
541 kw['parse_float'] = Decimal
--> 542 return cls(encoding=encoding, **kw).decode(s)
543
544

~\anaconda3\lib\site-packages\qiskit_ibm_provider\utils\json.py in init(self, *args, **kwargs)
266
267 def init(self, *args: Any, **kwargs: Any):
--> 268 super().init(object_hook=self.object_hook, *args, **kwargs)
269 self.__parameter_vectors: Dict[str, Tuple[ParameterVector, set]] = {}
270 self.__read_parameter_expression = (

TypeError: init() got an unexpected keyword argument 'encoding'

Steps to reproduce the problem

I first import the IBMProvider and get the backend

hub = "ibm-q-melbourne"
group = "unimelb"
project = "hub"
backend_name = 'ibm_perth'
hgp = f"{hub}/{group}/{project}"

provider = IBMProvider()
#account already saved
backend = provider.get_backend(backend_name, instance=hgp)

(Note the account was already saved here)

then I retrieve the job:
job = provider.backend.retrieve_job('cfu4j33mcdu7bt2gj250')
At this step, the error occured

What is the expected behavior?

Job object should be stored in job and no error should occur

Suggested solutions

According to the qiksit API references https://qiskit.org/documentation/partners/qiskit_ibm_provider/stubs/qiskit_ibm_provider.IBMProvider.html#qiskit_ibm_provider.IBMProvider
provider.backend should returns a IBMBackendService which has the retrieve_job method, and according to the file it should also work if I use provider.retrieve_job directly. However I test both none of them worked and both pops same error listed above.

@KangHaiYue KangHaiYue added the type: bug Something isn't working label Feb 28, 2023
@kt474 kt474 added this to the 0.6.1 milestone May 30, 2023
@merav-aharoni
Copy link
Collaborator

I tried to recreate this bug with the following script:

from qiskit_ibm_provider import IBMProvider
hub = "ibm-q"
group = "open"
project = "main"
backend_name = 'ibm_perth'
hgp = f"{hub}/{group}/{project}"

provider = IBMProvider()
jobs = provider.jobs(backend_name=backend_name)
backend = provider.get_backend(backend_name, instance=hgp)

job_id = jobs[0].job_id()
job = provider.retrieve_job(job_id=job_id)
print(job)

However, it worked fine (no exception). Probably need more information.

@kt474
Copy link
Member

kt474 commented Jun 1, 2023

I explained in this comment #649 (comment) but I believe the issue is that you have the simplejson package installed in your environment. Uninstalling this package should resolve the issue.

@0sophy1
Copy link

0sophy1 commented Jun 2, 2023

Hi @kt474 thank you fo finding the solution. I believe @YongsooHWANG also reported this issue with relating to simplejson and solved this by letting qiskit use simple json. I'll let him know as well.

@kt474
Copy link
Member

kt474 commented Jun 5, 2023

fixed by #649

@kt474 kt474 closed this as completed Jun 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants