From cfaae78556962c430de86c147b864b35a0d8f777 Mon Sep 17 00:00:00 2001 From: Kevin Tian Date: Thu, 15 Aug 2024 16:49:33 -0400 Subject: [PATCH] Remove session id "service" param deprecation (#1868) * Remove session id deprecation * Add release note --- qiskit_ibm_runtime/session.py | 18 +----------------- release-notes/unreleased/1868.other.rst | 1 + test/integration/test_session.py | 2 +- 3 files changed, 3 insertions(+), 18 deletions(-) create mode 100644 release-notes/unreleased/1868.other.rst diff --git a/qiskit_ibm_runtime/session.py b/qiskit_ibm_runtime/session.py index d2137afc4..46efe039d 100644 --- a/qiskit_ibm_runtime/session.py +++ b/qiskit_ibm_runtime/session.py @@ -17,7 +17,6 @@ from typing import Dict, Optional, Type, Union, Callable, Any from types import TracebackType from functools import wraps -import warnings from qiskit.providers.backend import BackendV1, BackendV2 @@ -351,18 +350,13 @@ def service(self) -> QiskitRuntimeService: return self._service @classmethod - def from_id( - cls, - session_id: str, - service: Optional[QiskitRuntimeService] = None, - ) -> "Session": + def from_id(cls, session_id: str, service: QiskitRuntimeService) -> "Session": """Construct a Session object with a given session_id Args: session_id: the id of the session to be created. This must be an already existing session id. service: instance of the ``QiskitRuntimeService`` class. - If ``None``, ``QiskitRuntimeService()`` is used to initialize your default saved account. Raises: IBMInputValueError: If given `session_id` does not exist. @@ -371,16 +365,6 @@ def from_id( A new Session with the given ``session_id`` """ - if not service: - warnings.warn( - ( - "The `service` parameter will be required in a future release no sooner than " - "3 months after the release of qiskit-ibm-runtime 0.23.0 ." - ), - DeprecationWarning, - stacklevel=2, - ) - service = QiskitRuntimeService() response = service._api_client.session_details(session_id) backend = response.get("backend_name") diff --git a/release-notes/unreleased/1868.other.rst b/release-notes/unreleased/1868.other.rst new file mode 100644 index 000000000..c3edaf1ab --- /dev/null +++ b/release-notes/unreleased/1868.other.rst @@ -0,0 +1 @@ +The ``service`` parameter is now required in ``Session.from_id()``. \ No newline at end of file diff --git a/test/integration/test_session.py b/test/integration/test_session.py index 355648289..79d7c8c7c 100644 --- a/test/integration/test_session.py +++ b/test/integration/test_session.py @@ -82,7 +82,7 @@ def test_session_from_id(self, service): except: raise SkipTest("No proper backends available") pm = generate_preset_pass_manager(backend=backend, optimization_level=1) - isa_circuit = pm.run(bell()) + isa_circuit = pm.run([bell()]) with Session(service, backend=backend) as session: sampler = SamplerV2(session=session) sampler.run(isa_circuit)