Skip to content

Commit

Permalink
Update msg & add to base_primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
kt474 committed Feb 26, 2024
1 parent 117628d commit a657a30
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 7 additions & 0 deletions qiskit_ibm_runtime/base_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .runtime_job import RuntimeJob
from .ibm_backend import IBMBackend
from .utils.default_session import get_cm_session
from .utils.deprecation import issue_deprecation_msg
from .utils.utils import validate_isa_circuits
from .constants import DEFAULT_DECODERS
from .qiskit_runtime_service import QiskitRuntimeService
Expand Down Expand Up @@ -122,6 +123,12 @@ def __init__(
raise ValueError(
"A backend or session must be specified when not using ibm_cloud channel."
)
issue_deprecation_msg(
"Not providing a backend is deprecated",
"0.21.0",
"Passing in a backend will be required, please provide a backend.",
3,
)
# Check if initialized within a IBMBackend session. If so, issue a warning.
if get_cm_provider_session():
warnings.warn(
Expand Down
12 changes: 5 additions & 7 deletions qiskit_ibm_runtime/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

"""Qiskit Runtime flexible session."""

import warnings
from typing import Dict, Optional, Type, Union, Callable, Any
from types import TracebackType
from functools import wraps
Expand All @@ -22,7 +21,7 @@
from .utils.result_decoder import ResultDecoder
from .ibm_backend import IBMBackend
from .utils.default_session import set_cm_session
from .utils.deprecation import deprecate_arguments
from .utils.deprecation import deprecate_arguments, issue_deprecation_msg
from .utils.converters import hms_to_seconds


Expand Down Expand Up @@ -116,11 +115,10 @@ def __init__(
if not backend:
if self._service.channel == "ibm_quantum":
raise ValueError('"backend" is required for ``ibm_quantum`` channel.')
warnings.warn(
"In a future release no sooner than 3 months after the release date of "
"qiskit-ibm-runtime version 0.21.0, "
"``backend`` will no longer be optional when using primitives. "
"Please provide a backend."
issue_deprecation_msg(
"Not providing a backend is deprecated",
"0.21.0",
"Passing in a backend will be required, please provide a backend.",
)

self._instance = None
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_missing_backend_cloud_warning(self):
"""Test warning if no backend provided on cloud channel."""
service = MagicMock()
service.channel = "ibm_cloud"
with self.assertWarns(UserWarning):
with self.assertWarns(DeprecationWarning):
Session(service=service)

def test_passing_ibm_backend(self):
Expand Down

0 comments on commit a657a30

Please sign in to comment.