Skip to content

Commit

Permalink
Exclude params on job retrieval by default (#1308)
Browse files Browse the repository at this point in the history
* exclude params on job retrieval by default

* add reno

* add test
  • Loading branch information
kt474 authored Jan 10, 2024
1 parent 781295b commit 872e391
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion qiskit_ibm_runtime/api/clients/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def program_run(
**hgp_dict,
)

def job_get(self, job_id: str, exclude_params: bool = None) -> Dict:
def job_get(self, job_id: str, exclude_params: bool = True) -> Dict:
"""Get job data.
Args:
Expand Down
2 changes: 1 addition & 1 deletion qiskit_ibm_runtime/runtime_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def inputs(self) -> Dict:
Input parameters used in this job.
"""
if not self._params:
response = self._api_client.job_get(job_id=self.job_id())
response = self._api_client.job_get(job_id=self.job_id(), exclude_params=False)
self._params = response.get("params", {})
return self._params

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Many methods in :class:`~qiskit_ibm_runtime.RuntimeJob` require retrieving the job data from the API with
``job_get()``. This API call will now exclude the ``params`` field by default because they are only necessary in
:meth:`qiskit_ibm_runtime.RuntimeJob.inputs`.
12 changes: 12 additions & 0 deletions test/integration/test_retrieve_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ def test_lazy_loading_params(self, service):
self.assertTrue(rjob.inputs)
self.assertTrue(rjob._params)

@run_integration_test
@quantum_only
def test_params_not_retrieved(self, service):
"""Test excluding params when unnecessary."""
job = self._run_program(service)
job.wait_for_final_state()

self.assertTrue(job.creation_date)
self.assertFalse(job._params)
self.assertTrue(job.inputs)
self.assertTrue(job._params)

@run_integration_test
def test_retrieve_all_jobs(self, service):
"""Test retrieving all jobs."""
Expand Down
2 changes: 1 addition & 1 deletion test/unit/mock/fake_runtime_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def program_run(
self._jobs[job_id] = job
return {"id": job_id, "backend": backend_name}

def job_get(self, job_id: str, exclude_params: bool = None) -> Any:
def job_get(self, job_id: str, exclude_params: bool = True) -> Any:
"""Get the specific job."""
return self._get_job(job_id, exclude_params).to_dict()

Expand Down

0 comments on commit 872e391

Please sign in to comment.