From 583b2265e827395e5376e7defce63d5d58a7cdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Tue, 28 Jan 2025 14:30:27 +0100 Subject: [PATCH 1/4] Dperecate run_experiment --- qiskit/providers/basic_provider/basic_simulator.py | 7 +++++++ .../notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml diff --git a/qiskit/providers/basic_provider/basic_simulator.py b/qiskit/providers/basic_provider/basic_simulator.py index e412867a0e19..9c7741a8b2c2 100644 --- a/qiskit/providers/basic_provider/basic_simulator.py +++ b/qiskit/providers/basic_provider/basic_simulator.py @@ -593,6 +593,13 @@ def _run_job(self, job_id: str, qobj: QasmQobj) -> Result: return Result.from_dict(result) + @deprecate_func( + since="1.4.0", + removal_timeline="in Qiskit 2.0.0", + additional_msg="This method takes a `QasmQobjExperiment` as input argument. " + "The `Qobj` class and related functionality are part of the deprecated " + "`BackendV1` workflow, and no longer necessary for `BackendV2`. Use `run` instead.", + ) def run_experiment(self, experiment: QasmQobjExperiment) -> dict[str, ...]: """Run an experiment (circuit) and return a single experiment result. diff --git a/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml b/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml new file mode 100644 index 000000000000..15b828db4124 --- /dev/null +++ b/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml @@ -0,0 +1,6 @@ +--- +deprecations_providers: + - | + The :meth:`.BasicSimulator.run_experiment` method has been deprecated and will be removed in Qiskit 2.0.0. + The method takes `QasmQobjExperiment` as input argument, which has been deprecated together with the `Qobj` + class and other related functionality. You can `run` with a :class:`.QuantumCircuit` input instead. \ No newline at end of file From f2ef7b8fef109cd471aa51bd985312352d44b613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Tue, 28 Jan 2025 14:49:32 +0100 Subject: [PATCH 2/4] Do not raise warning with internal calls --- qiskit/providers/basic_provider/basic_simulator.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qiskit/providers/basic_provider/basic_simulator.py b/qiskit/providers/basic_provider/basic_simulator.py index 9c7741a8b2c2..dac4bff46781 100644 --- a/qiskit/providers/basic_provider/basic_simulator.py +++ b/qiskit/providers/basic_provider/basic_simulator.py @@ -576,8 +576,14 @@ def _run_job(self, job_id: str, qobj: QasmQobj) -> Result: self._memory = getattr(qobj.config, "memory", False) self._qobj_config = qobj.config start = time.time() - for experiment in qobj.experiments: - result_list.append(self.run_experiment(experiment)) + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + category=DeprecationWarning, + message=r".+qiskit\.providers\.basic_provider\.basic_simulator\..+", + ) + for experiment in qobj.experiments: + result_list.append(self.run_experiment(experiment)) end = time.time() result = { "backend_name": self.name, From 646397c64a74ff3015f89efaa80952228d73ab6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= <57907331+ElePT@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:47:43 +0100 Subject: [PATCH 3/4] Add class links Co-authored-by: Julien Gacon --- .../notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml b/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml index 15b828db4124..e79ca8d48910 100644 --- a/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml +++ b/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml @@ -2,5 +2,6 @@ deprecations_providers: - | The :meth:`.BasicSimulator.run_experiment` method has been deprecated and will be removed in Qiskit 2.0.0. - The method takes `QasmQobjExperiment` as input argument, which has been deprecated together with the `Qobj` - class and other related functionality. You can `run` with a :class:`.QuantumCircuit` input instead. \ No newline at end of file + The method takes :class:`.QasmQobjExperiment` as input argument, which has been deprecated together + with the :class:`.Qobj` class and other related functionality. You can call :class:`.BasicSimulator.run` + with a :class:`.QuantumCircuit` input instead. \ No newline at end of file From 44f9d380b6f73cb03f689d9feba933c67d421f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= <57907331+ElePT@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:50:29 +0100 Subject: [PATCH 4/4] Apply Eli's suggestion --- .../notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml b/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml index e79ca8d48910..34dd5cc80c3c 100644 --- a/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml +++ b/releasenotes/notes/deprecate-run-experiment-f37b3f35724bc6bb.yaml @@ -3,5 +3,5 @@ deprecations_providers: - | The :meth:`.BasicSimulator.run_experiment` method has been deprecated and will be removed in Qiskit 2.0.0. The method takes :class:`.QasmQobjExperiment` as input argument, which has been deprecated together - with the :class:`.Qobj` class and other related functionality. You can call :class:`.BasicSimulator.run` + with the :class:`.Qobj` class and other related functionality. You can call :meth:`.BasicSimulator.run` with a :class:`.QuantumCircuit` input instead. \ No newline at end of file