From 6bf670a412440a9ca475f7b7582dd98470489741 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Mon, 8 Jan 2024 18:32:40 -0500 Subject: [PATCH 1/3] exclude params on job retrieval by default --- qiskit_ibm_runtime/api/clients/runtime.py | 2 +- qiskit_ibm_runtime/runtime_job.py | 2 +- test/unit/mock/fake_runtime_client.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qiskit_ibm_runtime/api/clients/runtime.py b/qiskit_ibm_runtime/api/clients/runtime.py index b895b8644..e1e08c499 100644 --- a/qiskit_ibm_runtime/api/clients/runtime.py +++ b/qiskit_ibm_runtime/api/clients/runtime.py @@ -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: diff --git a/qiskit_ibm_runtime/runtime_job.py b/qiskit_ibm_runtime/runtime_job.py index 894353d41..ebb2ad9ce 100644 --- a/qiskit_ibm_runtime/runtime_job.py +++ b/qiskit_ibm_runtime/runtime_job.py @@ -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 diff --git a/test/unit/mock/fake_runtime_client.py b/test/unit/mock/fake_runtime_client.py index fb27ffefc..ba514edb0 100644 --- a/test/unit/mock/fake_runtime_client.py +++ b/test/unit/mock/fake_runtime_client.py @@ -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() From 40c0a418116cc6ead8e5450b5c3d40abd3dcb119 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Mon, 8 Jan 2024 18:40:41 -0500 Subject: [PATCH 2/3] add reno --- .../notes/exclude-job-params-default-00133498a5c5c15d.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 releasenotes/notes/exclude-job-params-default-00133498a5c5c15d.yaml diff --git a/releasenotes/notes/exclude-job-params-default-00133498a5c5c15d.yaml b/releasenotes/notes/exclude-job-params-default-00133498a5c5c15d.yaml new file mode 100644 index 000000000..6d500c8e1 --- /dev/null +++ b/releasenotes/notes/exclude-job-params-default-00133498a5c5c15d.yaml @@ -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`. From bf1ce747382455b23fed82af1a7872693e25d84e Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Mon, 8 Jan 2024 20:22:04 -0500 Subject: [PATCH 3/3] add test --- test/integration/test_retrieve_job.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/integration/test_retrieve_job.py b/test/integration/test_retrieve_job.py index 5997a9e62..c2105ce19 100644 --- a/test/integration/test_retrieve_job.py +++ b/test/integration/test_retrieve_job.py @@ -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."""