From d575e43788f8374b5838511d1801efd2bc995502 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Wed, 9 Aug 2023 12:22:03 -0400 Subject: [PATCH 1/8] wip don't store params --- .github/workflows/integration-tests.yml | 1 - qiskit_ibm_runtime/runtime_job.py | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index a3c6c2cf4..f9293a578 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -18,7 +18,6 @@ on: workflow_dispatch: jobs: integration-tests: - if: github.repository_owner == 'Qiskit' name: Run integration tests - ${{ matrix.environment }} runs-on: ${{ matrix.os }} strategy: diff --git a/qiskit_ibm_runtime/runtime_job.py b/qiskit_ibm_runtime/runtime_job.py index 54200f772..d4fdaf13c 100644 --- a/qiskit_ibm_runtime/runtime_job.py +++ b/qiskit_ibm_runtime/runtime_job.py @@ -98,13 +98,13 @@ def __init__( job_id: str, program_id: str, service: "qiskit_runtime_service.QiskitRuntimeService", - params: Optional[Dict] = None, creation_date: Optional[str] = None, user_callback: Optional[Callable] = None, result_decoder: Optional[Union[Type[ResultDecoder], Sequence[Type[ResultDecoder]]]] = None, image: Optional[str] = "", session_id: Optional[str] = None, tags: Optional[List] = None, + **kwargs: Any, ) -> None: """RuntimeJob constructor. @@ -114,7 +114,6 @@ def __init__( client_params: Parameters used for server connection. job_id: Job ID. program_id: ID of the program this job is for. - params: Job parameters. creation_date: Job creation date, in UTC. user_callback: User callback function. result_decoder: A :class:`ResultDecoder` subclass used to decode job results. @@ -127,7 +126,7 @@ def __init__( self._api_client = api_client self._results: Optional[Any] = None self._interim_results: Optional[Any] = None - self._params = params or {} + self._params: Dict[str, Any] = None self._creation_date = creation_date self._program_id = program_id self._status = JobStatus.INITIALIZING From 029c3c4c3676f1baf2b4ec864f65e26ae41e96b1 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Wed, 9 Aug 2023 12:41:14 -0400 Subject: [PATCH 2/8] fix unit tests --- test/unit/mock/fake_runtime_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/mock/fake_runtime_client.py b/test/unit/mock/fake_runtime_client.py index 989905ef9..4bafd1ac7 100644 --- a/test/unit/mock/fake_runtime_client.py +++ b/test/unit/mock/fake_runtime_client.py @@ -148,7 +148,7 @@ def to_dict(self): "project": self._project, "backend": self._backend_name, "state": {"status": self._status, "reason": self._reason}, - "params": [self._params], + "params": self._params, "program": {"id": self._program_id}, "image": self._image, } From af3599a0c79fc93b9389f83219623c75038a8cf9 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Wed, 16 Aug 2023 15:25:24 -0400 Subject: [PATCH 3/8] default params value --- qiskit_ibm_runtime/runtime_job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_ibm_runtime/runtime_job.py b/qiskit_ibm_runtime/runtime_job.py index 8a28632b7..ca50aa22e 100644 --- a/qiskit_ibm_runtime/runtime_job.py +++ b/qiskit_ibm_runtime/runtime_job.py @@ -126,7 +126,7 @@ def __init__( self._api_client = api_client self._results: Optional[Any] = None self._interim_results: Optional[Any] = None - self._params: Dict[str, Any] = None + self._params: Dict[str, Any] = {} self._creation_date = creation_date self._program_id = program_id self._status = JobStatus.INITIALIZING From ee96851cba1d63dc54e6be064a36d272f09ad102 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Tue, 22 Aug 2023 15:26:08 -0400 Subject: [PATCH 4/8] update custom test/serialization --- test/serialization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/serialization.py b/test/serialization.py index 2ab0945c5..e2dfde575 100644 --- a/test/serialization.py +++ b/test/serialization.py @@ -43,7 +43,7 @@ def from_json(cls, json_str): return cls(**json.loads(json_str)) def __eq__(self, other): - return self.value == other.value + return self.value == self.from_json(other).value class SerializableClassDecoder(ResultDecoder): From d2419e22d546deaaa2b8f88a22d8acb699fe0a39 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Tue, 22 Aug 2023 15:54:49 -0400 Subject: [PATCH 5/8] reno, update custom serialization --- .../notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml | 5 +++++ test/serialization.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml diff --git a/releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml b/releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml new file mode 100644 index 000000000..f495435c6 --- /dev/null +++ b/releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + Circuits will no longer be automatically stored in runtime jobs. They can still be retrieved + normally with :meth:`qiskit_ibm_runtime.RuntimeJob.inputs`. diff --git a/test/serialization.py b/test/serialization.py index e2dfde575..372cea5dd 100644 --- a/test/serialization.py +++ b/test/serialization.py @@ -43,7 +43,9 @@ def from_json(cls, json_str): return cls(**json.loads(json_str)) def __eq__(self, other): - return self.value == self.from_json(other).value + if isinstance(other, str): + return self.value == self.from_json(other).value + return self.value == other.value class SerializableClassDecoder(ResultDecoder): From 8131afdf3eca71bc28a7c056b44671a6688d782f Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Tue, 22 Aug 2023 16:14:19 -0400 Subject: [PATCH 6/8] add test --- .github/workflows/integration-tests.yml | 1 + test/integration/test_job.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f9293a578..a3c6c2cf4 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -18,6 +18,7 @@ on: workflow_dispatch: jobs: integration-tests: + if: github.repository_owner == 'Qiskit' name: Run integration tests - ${{ matrix.environment }} runs-on: ${{ matrix.os }} strategy: diff --git a/test/integration/test_job.py b/test/integration/test_job.py index 0beb0f435..f22b181af 100644 --- a/test/integration/test_job.py +++ b/test/integration/test_job.py @@ -320,6 +320,14 @@ def test_updating_job_tags(self, service): job.update_tags(new_job_tag) self.assertTrue(job.tags, new_job_tag) + @run_integration_test + def test_circuit_params_not_stored(self, service): + """Test that circuits are not automatically stored in the job params.""" + job = self._run_program(service) + job.wait_for_final_state() + self.assertFalse(job._params) + self.assertTrue(job.inputs) + def _assert_complex_types_equal(self, expected, received): """Verify the received data in complex types is expected.""" if "serializable_class" in received: From 0e9921f793e24549b4554f9052346a5265b31ae3 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Wed, 23 Aug 2023 12:53:17 -0400 Subject: [PATCH 7/8] add params back, remove from run --- qiskit_ibm_runtime/qiskit_runtime_service.py | 1 - qiskit_ibm_runtime/runtime_job.py | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qiskit_ibm_runtime/qiskit_runtime_service.py b/qiskit_ibm_runtime/qiskit_runtime_service.py index 683ef2a6c..401e66c65 100644 --- a/qiskit_ibm_runtime/qiskit_runtime_service.py +++ b/qiskit_ibm_runtime/qiskit_runtime_service.py @@ -1023,7 +1023,6 @@ def run( client_params=self._client_params, job_id=response["id"], program_id=program_id, - params=inputs, user_callback=callback, result_decoder=result_decoder, image=qrt_options.image, diff --git a/qiskit_ibm_runtime/runtime_job.py b/qiskit_ibm_runtime/runtime_job.py index ca50aa22e..43a5d0f62 100644 --- a/qiskit_ibm_runtime/runtime_job.py +++ b/qiskit_ibm_runtime/runtime_job.py @@ -98,13 +98,13 @@ def __init__( job_id: str, program_id: str, service: "qiskit_runtime_service.QiskitRuntimeService", + params: Optional[Dict] = None, creation_date: Optional[str] = None, user_callback: Optional[Callable] = None, result_decoder: Optional[Union[Type[ResultDecoder], Sequence[Type[ResultDecoder]]]] = None, image: Optional[str] = "", session_id: Optional[str] = None, tags: Optional[List] = None, - **kwargs: Any, ) -> None: """RuntimeJob constructor. @@ -114,6 +114,7 @@ def __init__( client_params: Parameters used for server connection. job_id: Job ID. program_id: ID of the program this job is for. + params: Job parameters. creation_date: Job creation date, in UTC. user_callback: User callback function. result_decoder: A :class:`ResultDecoder` subclass used to decode job results. @@ -126,7 +127,7 @@ def __init__( self._api_client = api_client self._results: Optional[Any] = None self._interim_results: Optional[Any] = None - self._params: Dict[str, Any] = {} + self._params = params or {} self._creation_date = creation_date self._program_id = program_id self._status = JobStatus.INITIALIZING From 8e66b0aa54166fc7cadc78e2e2f27d7412a6a94f Mon Sep 17 00:00:00 2001 From: Kevin Tian Date: Wed, 23 Aug 2023 12:54:01 -0400 Subject: [PATCH 8/8] Update releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml Co-authored-by: merav-aharoni --- .../notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml b/releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml index f495435c6..a098bb8cb 100644 --- a/releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml +++ b/releasenotes/notes/dont-store-circuit-params-9d87ffefc2a7d257.yaml @@ -1,5 +1,5 @@ --- upgrade: - | - Circuits will no longer be automatically stored in runtime jobs. They can still be retrieved - normally with :meth:`qiskit_ibm_runtime.RuntimeJob.inputs`. + Circuits and other input parameters will no longer be automatically stored in runtime jobs. They can still be retrieved + with :meth:`qiskit_ibm_runtime.RuntimeJob.inputs`.