Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Elena Peña Tapia <[email protected]>
  • Loading branch information
1ucian0 and ElePT authored Jul 30, 2024
1 parent ce993d7 commit 5db7ec3
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 53 deletions.
2 changes: 1 addition & 1 deletion qiskit/circuit/add_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def control(
) -> ControlledGate:
"""Return controlled version of gate using controlled rotations. This function
first checks the name of the operation to see if it knows of a method from which
to generate a controlled version. Currently, these are `x`, `rx`, `ry`, and `rz`.
to generate a controlled version. Currently, these are ``x``, ``rx``, ``ry``, and ``rz``.
If a method is not directly known, it calls the unroller to convert to `u1`, `u3`,
and `cx` gates.
Expand Down
7 changes: 3 additions & 4 deletions qiskit/providers/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ class BackendV1(Backend, ABC):
@deprecate_func(
since="1.2",
removal_timeline="in the 2.0 release",
additional_msg="If this backend is only a hardware description, consider constructing a "
"Target. If the provider also provides access for execution, it can construct "
"Primitives. Alternatebly, consider moving to BackendV2 "
"(see https://qisk.it/backendV1-to-V2).",
additional_msg="If the backend only encapsulates a hardware description, consider constructing a "
"Target directly. If it is part of a provider that gives access to execution, consider using Primitives instead. "
"Alternatively, consider moving to BackendV2 (see https://qisk.it/backendV1-to-V2).",
)
def __init__(self, configuration, provider=None, **fields):
"""Initialize a backend class
Expand Down
3 changes: 0 additions & 3 deletions qiskit/providers/basic_provider/basic_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ def configuration(self) -> BackendConfiguration:
]

with warnings.catch_warnings():
# This is a temporary conversion step to allow for a smoother transition
# to a fully target-based transpiler pipeline while maintaining the behavior
# of `transpile` with BackendV1 inputs.
# TODO Provider models are deprecated
# https://github.com/Qiskit/qiskit/issues/12843
warnings.filterwarnings(
Expand Down
2 changes: 1 addition & 1 deletion qiskit/providers/fake_provider/fake_qasm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _set_props_from_json(self):
props = self._load_json(self.props_filename)
decode_backend_properties(props)
with warnings.catch_warnings():
# This raises BackendProperties internally
# This raises the BackendProperties deprecation warning internally
warnings.filterwarnings("ignore", category=DeprecationWarning, module="qiskit")
self._properties = BackendProperties.from_dict(props)

Expand Down
2 changes: 1 addition & 1 deletion qiskit/providers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
warnings.warn(
"qiskit.providers.models is deprecated since Qiskit 1.2 and will be removed in Qiskit 2.0."
"With the removal of Qobj, there is no need for these schema-conformant objects. If you still need"
"to use them, it could be because you are using a BackendV1, which it is also deprecated in favor"
"to use them, it could be because you are using a BackendV1, which is also deprecated in favor"
"of BackendV2",
DeprecationWarning,
2,
Expand Down
32 changes: 17 additions & 15 deletions qiskit/providers/models/backendconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class GateConfig:
@deprecate_func(
since="1.2",
removal_timeline="in the 2.0 release",
additional_msg="This class is not necessary for BackendV2. If user still need Qobj, "
"that probably means that they are using a backend based on the "
"deprecated BackendV1 class.",
additional_msg="The models in ``qiskit.providers.models`` are part "
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
"workflow requires these representations it likely relies on deprecated functionality and "
"should be updated to use `BackendV2`.",
stacklevel=3,
)
def __init__(
Expand Down Expand Up @@ -153,9 +154,10 @@ class UchannelLO:
@deprecate_func(
since="1.2",
removal_timeline="in the 2.0 release",
additional_msg="This class is not necessary for BackendV2. If user still need Qobj, "
"that probably means that they are using a backend based on the "
"deprecated BackendV1 class.",
additional_msg="The models in ``qiskit.providers.models`` are part "
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
"workflow requires these representations it likely relies on deprecated functionality and "
"should be updated to use `BackendV2`.",
)
def __init__(self, q, scale):
"""Initialize a UchannelLOSchema object
Expand Down Expand Up @@ -230,9 +232,9 @@ class QasmBackendConfiguration:
@deprecate_func(
since="1.2",
removal_timeline="in the 2.0 release",
additional_msg="The models in ``qiskit.providers.models`` and related objects are part "
"of the deprecated `BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
"workflow requires `Qobj` it likely relies on deprecated functionality and "
additional_msg="The models in ``qiskit.providers.models`` are part "
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
"workflow requires these representations it likely relies on deprecated functionality and "
"should be updated to use `BackendV2`.",
stacklevel=3,
)
Expand Down Expand Up @@ -521,9 +523,9 @@ class BackendConfiguration(QasmBackendConfiguration):
@deprecate_func(
since="1.2",
removal_timeline="in the 2.0 release",
additional_msg="The models in ``qiskit.providers.models`` and related objects are part "
"of the deprecated `BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
"workflow requires `Qobj` it likely relies on deprecated functionality and "
additional_msg="The models in ``qiskit.providers.models`` are part "
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
"workflow requires these representations it likely relies on deprecated functionality and "
"should be updated to use `BackendV2`.",
stacklevel=3,
)
Expand All @@ -539,9 +541,9 @@ class PulseBackendConfiguration(QasmBackendConfiguration):
@deprecate_func(
since="1.2",
removal_timeline="in the 2.0 release",
additional_msg="The models in ``qiskit.providers.models`` and related objects are part "
"of the deprecated `BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
"workflow requires `Qobj` it likely relies on deprecated functionality and "
additional_msg="The models in ``qiskit.providers.models`` are part "
"of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user "
"workflow requires these representations it likely relies on deprecated functionality and "
"should be updated to use `BackendV2`.",
stacklevel=3,
)
Expand Down
7 changes: 4 additions & 3 deletions qiskit/providers/models/backendproperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ class BackendProperties:
@deprecate_func(
since="1.2",
removal_timeline="in the 2.0 release",
additional_msg="This class is not necessary for BackendV2. If user still need Qobj, "
"that probably means that they are using a backend based on the "
"deprecated BackendV1 class.",
additional_msg="The models in ``qiskit.providers.models`` and related objects are part "
"of the deprecated `BackendV1` workflow, and no longer necessary for `BackendV2`. If a user "
"workflow requires these representations it likely relies on deprecated functionality and "
"should be updated to use `BackendV2`.",
stacklevel=3,
)
def __init__(
Expand Down
16 changes: 0 additions & 16 deletions qiskit/transpiler/preset_passmanagers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,6 @@
.. autofunction:: generate_scheduling
.. currentmodule:: qiskit.transpiler.preset_passmanagers
"""
import copy
import warnings

from qiskit.circuit.controlflow import CONTROL_FLOW_OP_NAMES
from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping
from qiskit.providers.backend_compat import BackendV2Converter

from qiskit.transpiler.instruction_durations import InstructionDurations
from qiskit.transpiler.timing_constraints import TimingConstraints

from qiskit.transpiler.passmanager_config import PassManagerConfig
from qiskit.transpiler.target import Target, target_to_backend_properties
from qiskit.transpiler import CouplingMap

from qiskit.transpiler.exceptions import TranspilerError

from .generate_preset_pass_manager import generate_preset_pass_manager
from .level0 import level_0_pass_manager
from .level1 import level_1_pass_manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def generate_preset_pass_manager(
timing_constraints = target.timing_constraints()
if backend_properties is None:
with warnings.catch_warnings():
# TODO this branch (targe-to-properties) is going to be removed soon (1.3) in favor
# TODO this approach (target-to-properties) is going to be removed soon (1.3) in favor
# of backend-to-target approach
warnings.filterwarnings(
"ignore",
Expand Down
6 changes: 3 additions & 3 deletions qiskit/transpiler/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,9 +1169,9 @@ def from_configuration(
@deprecate_func(
since="1.2",
removal_timeline="in the 2.0 release",
additional_msg="This function is not necessary for BackendV2. If user still need Qobj, that "
"probably means that they are using a backend based on the deprecated BackendV1 "
"class.",
additional_msg="This method is used to build an element from the deprecated ``qiskit.providers.models`` module. "
"These models are part of the deprecated `BackendV1` workflow and no longer necessary for `BackendV2`. If a user workflow requires these representations it likely relies on deprecated functionality and "
"should be updated to use `BackendV2`.",
)
def target_to_backend_properties(target: Target):
"""Convert a :class:`~.Target` object into a legacy :class:`~.BackendProperties`"""
Expand Down
2 changes: 1 addition & 1 deletion qiskit/utils/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def deprecate_func(
is_property: If the deprecated function is a `@property`, set this to True so that the
generated message correctly describes it as such. (This isn't necessary for
property setters, as their docstring is ignored by Python.)
stacklevel: It will be pass to :func:`warnings.warn`.
stacklevel: Stack level passed to :func:`warnings.warn`.
Returns:
Callable: The decorated callable.
"""
Expand Down
9 changes: 5 additions & 4 deletions releasenotes/notes/backendv1-d0d0642ed38fed3c.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
deprecations_providers:
- |
BackendV1 is deprecated and it will be removed not earlier than the next major release.
If providers want to explose a backend only as a hardware description, consider constructing a :class:`.Target`.
If the provider also provides access for execution, that can be done via the primitives interfaces.
Alternatebly, if the previous model is prefered, consider moving to :class:`.BackendV2` (see https://qisk.it/backendV1-to-V2).
The ``BackendV1`` class is deprecated and it will be removed not earlier than the next major release.
There are several migration paths available depending on the main purpose of the backend object:
- To expose backend information with no access to execution (just a hardware description), consider constructing a :class:`.Target` directly.
- To provides access to execution capabilities, consider relying on the primitives interfaces instead.
- Alternatively, to continue providing simultaneous :class:`.Target` (hardware information) and ``run`` (execution) capabilities, consider moving to :class:`.BackendV2` (see https://qisk.it/backendV1-to-V2).

0 comments on commit 5db7ec3

Please sign in to comment.