Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qpy deprecation warning class #11260

Merged
merged 5 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion qiskit/qpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
0.29.0. However, loading that QPY file with 0.18.0 is not supported and may not
work.

If a feature being loaded is deprecated in the corresponding qiskit release, QPY will
raise a :exc:`~.QPYLoadingDeprecatedFeatureWarning` informing of the deprecation period
and how the feature will be internally handled.

.. autoexception:: QPYLoadingDeprecatedFeatureWarning

.. _qpy_format:

**********
Expand Down Expand Up @@ -1335,7 +1341,7 @@ class if it's defined in Qiskit. Otherwise it falls back to the custom
.. [#f3] https://docs.python.org/3/c-api/complex.html#c.Py_complex
"""

from .exceptions import QpyError
from .exceptions import QpyError, QPYLoadingDeprecatedFeatureWarning
from .interface import dump, load

# For backward compatibility. Provide, Runtime, Experiment call these private functions.
Expand Down
4 changes: 2 additions & 2 deletions qiskit/qpy/binary_io/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from qiskit.pulse.schedule import ScheduleBlock
from qiskit.qpy import formats, common, type_keys
from qiskit.qpy.binary_io import value
from qiskit.qpy.exceptions import QpyError
from qiskit.qpy.exceptions import QpyError, QPYLoadingDeprecatedFeatureWarning
from qiskit.pulse.configuration import Kernel, Discriminator


Expand Down Expand Up @@ -162,7 +162,7 @@ def _read_symbolic_pulse(file_obj, version):
"Complex amp support for symbolic library pulses will be deprecated. "
"Once deprecated, library pulses loaded from old QPY files (Terra version < 0.23),"
" will be converted automatically to float (amp,angle) representation.",
PendingDeprecationWarning,
QPYLoadingDeprecatedFeatureWarning,
)
class_name = "ScalableSymbolicPulse"

Expand Down
7 changes: 6 additions & 1 deletion qiskit/qpy/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
# (C) Copyright IBM 2022, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -26,3 +26,8 @@ def __init__(self, *message):
def __str__(self):
"""Return the message."""
return repr(self.message)


class QPYLoadingDeprecatedFeatureWarning(UserWarning):
"""Visible deprecation warning for QPY loading functions without
a stable point in the call stack."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
features:
- |
A new exception, :exc:`~.QPYLoadingDeprecatedFeatureWarning`, has been added to the QPY module.
This class allows for deprecation warnings to surface even if the depreacted feature
is in a variable point in the call stack, as is the case for many QPY loading functions that
are called recursively.