Skip to content

Commit

Permalink
Remove session id "service" param deprecation (#1868)
Browse files Browse the repository at this point in the history
* Remove session id deprecation

* Add release note
  • Loading branch information
kt474 authored Aug 15, 2024
1 parent 99d84c5 commit cfaae78
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
18 changes: 1 addition & 17 deletions qiskit_ibm_runtime/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions release-notes/unreleased/1868.other.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``service`` parameter is now required in ``Session.from_id()``.
2 changes: 1 addition & 1 deletion test/integration/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cfaae78

Please sign in to comment.