Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude params on job retrieval by default #1308

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading