From 3eddcdda35688d31209e0276f4dbc62ab4aec8e1 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Tue, 14 Nov 2023 14:18:59 -0500 Subject: [PATCH 01/11] Replace qiskit-terra dependency with qiskit dependency This change brings qiskit-experiments in line with other packages like qiskit-ibm-provider and qiskit-aer and prepares for the deprecation of the qiskit-terra package. The effective minimum version of qiskit-terra is bumped up one minor version from 0.24 to 0.25 (linked to qiskit 0.44) as part of this change, but since qiskit 0.45 has already been released this should not be an impactful change for most users. --- .../notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml | 10 ++++++++++ requirements.txt | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml diff --git a/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml b/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml new file mode 100644 index 0000000000..cc5d5c561f --- /dev/null +++ b/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml @@ -0,0 +1,10 @@ +--- +upgrade: + - | + The dependency on ``qiskit-terra`` was replaced with a dependency on + ``qiskit``. This change follows move in upstream Qiskit to rename + ``qiskit-terra`` to ``qiskit``. For more information see `the Qiskit + repository renaming plan + `__ + and the `Qiskit issue `__ + for the renaming of the package. diff --git a/requirements.txt b/requirements.txt index 7264029843..20f645b1a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ numpy>=1.17 scipy>=1.4 -qiskit-terra>=0.24 +qiskit>=0.44 qiskit-ibm-experiment>=0.3.4 matplotlib>=3.4 uncertainties From 4cd7b50d1c26e094db5428b822b3b4ba74fef6e8 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 14:34:37 -0500 Subject: [PATCH 02/11] Replace package/repo references to qiskit-terra with qiskit --- requirements-dev.txt | 2 +- tox.ini | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 3ba0a3a7ec..24c7719517 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -qiskit-terra>=0.45.0 +qiskit>=0.45.0 black~=22.0 fixtures stestr diff --git a/tox.ini b/tox.ini index bc7596d0bc..c5b5f63af4 100644 --- a/tox.ini +++ b/tox.ini @@ -40,7 +40,7 @@ setenv = QISKIT_SUPPRESS_PACKAGING_WARNINGS=Y QISKIT_TEST_CAPTURE_STREAMS=1 deps = - git+https://github.com/Qiskit/qiskit-terra + git+https://github.com/Qiskit/qiskit -r{toxinidir}/requirements-dev.txt -r{toxinidir}/requirements-extras.txt passenv = @@ -114,7 +114,7 @@ passenv = RELEASE_STRING VERSION_STRING deps = - git+https://github.com/Qiskit/qiskit-terra + git+https://github.com/Qiskit/qiskit -r{toxinidir}/requirements-dev.txt -r{toxinidir}/requirements-extras.txt commands = From 7a877ffed62c8797ac9e93c4a2d55c1882a60ed8 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 14:36:24 -0500 Subject: [PATCH 03/11] Remove workarounds for aquire_alignment misspelling --- qiskit_experiments/framework/backend_data.py | 5 +---- test/framework/test_backend_timing.py | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/qiskit_experiments/framework/backend_data.py b/qiskit_experiments/framework/backend_data.py index ee2e9567d1..1f0b589523 100644 --- a/qiskit_experiments/framework/backend_data.py +++ b/qiskit_experiments/framework/backend_data.py @@ -146,10 +146,7 @@ def acquire_alignment(self): if self._v1: return self._backend.configuration().timing_constraints.get("acquire_alignment", 1) elif self._v2: - # currently has a typo in terra - if hasattr(self._backend.target, "acquire_alignment"): - return self._backend.target.acquire_alignment - return self._backend.target.aquire_alignment + return self._backend.target.acquire_alignment except AttributeError: return 1 return 1 diff --git a/test/framework/test_backend_timing.py b/test/framework/test_backend_timing.py index 5423106e63..a4b64f4075 100644 --- a/test/framework/test_backend_timing.py +++ b/test/framework/test_backend_timing.py @@ -33,13 +33,10 @@ def setUpClass(cls): # terra. Just to be safe, we check that the properties we care about # for these tests are never changed from what the tests assume. backend = FakeNairobiV2() - # Using BackendData to handle acquire/aquire rename. Can replace with - # target.acquire_alignment when testing against terra >=0.24 - backend_data = BackendData(backend) target = backend.target assumptions = ( (abs(target.dt * 4.5e9 - 1) < 1e-6) - and backend_data.acquire_alignment == 16 + and target.acquire_alignment == 16 and target.pulse_alignment == 1 and target.min_length == 64 and target.granularity == 16 @@ -47,7 +44,7 @@ def setUpClass(cls): if not assumptions: # pragma: no cover raise ValueError("FakeNairobiV2 properties have changed!") - cls.acquire_alignment = backend_data.acquire_alignment + cls.acquire_alignment = target.acquire_alignment cls.dt = target.dt cls.granularity = target.granularity cls.min_length = target.min_length From d77779ab1ce7b5b97a0f1cf7808b982ea25e553f Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 14:37:18 -0500 Subject: [PATCH 04/11] Simplify logging of qiskit version --- qiskit_experiments/database_service/utils.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/qiskit_experiments/database_service/utils.py b/qiskit_experiments/database_service/utils.py index 2b6e3b13be..4a2fc68759 100644 --- a/qiskit_experiments/database_service/utils.py +++ b/qiskit_experiments/database_service/utils.py @@ -12,6 +12,7 @@ """Experiment utility functions.""" +import importlib.metadata import io import logging import threading @@ -26,25 +27,19 @@ import pkg_resources from dateutil import tz -from qiskit.version import __version__ as terra_version - from qiskit_ibm_experiment import ( IBMExperimentEntryExists, IBMExperimentEntryNotFound, ) from .exceptions import ExperimentEntryNotFound, ExperimentEntryExists, ExperimentDataError -from ..version import __version__ as experiments_version LOG = logging.getLogger(__name__) def qiskit_version(): """Return the Qiskit version.""" - try: - return pkg_resources.get_distribution("qiskit").version - except Exception: # pylint: disable=broad-except - return {"qiskit-terra": terra_version, "qiskit-experiments": experiments_version} + return importlib.metadata.distribution("qiskit").version def parse_timestamp(utc_dt: Union[datetime, str]) -> datetime: From 12cc33705cb62fd65c81ecf4ddee5a797af0e1d8 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 14:38:20 -0500 Subject: [PATCH 05/11] Remove stray references to terra --- .pylintrc | 2 +- constraints.txt | 4 ++-- qiskit_experiments/framework/backend_data.py | 8 ++++---- .../data/generate_clifford_data.py | 2 -- test/framework/test_backend_timing.py | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.pylintrc b/.pylintrc index 61be1ca41d..22f47fd59f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -73,7 +73,7 @@ disable=fixme, # disabled as TODOs would show up as warnings cyclic-import, # This checker raises on all module pairs that import each other, # even submodules that only import already loaded objects from a # parent module, a common pattern in qiskit-experiments. - assigning-non-slot # https://github.com/Qiskit/qiskit-terra/pull/7347#issuecomment-985007311 + assigning-non-slot # https://github.com/Qiskit/qiskit/pull/7347#issuecomment-985007311 diff --git a/constraints.txt b/constraints.txt index cd066084df..fffba16557 100644 --- a/constraints.txt +++ b/constraints.txt @@ -1,4 +1,4 @@ # Numpy 1.25 deprecated some behaviours that we used, and caused some -# tests to flake. See https://github.com/Qiskit/qiskit-terra/issues/10305, +# tests to flake. See https://github.com/Qiskit/qiskit/issues/10305, # remove pin when resolving that. -numpy<1.25 \ No newline at end of file +numpy<1.25 diff --git a/qiskit_experiments/framework/backend_data.py b/qiskit_experiments/framework/backend_data.py index 1f0b589523..93ed671d6d 100644 --- a/qiskit_experiments/framework/backend_data.py +++ b/qiskit_experiments/framework/backend_data.py @@ -32,10 +32,10 @@ def __init__(self, backend): self._parse_additional_data() def _parse_additional_data(self): - # data specific parsing not done yet in qiskit-terra + # data specific parsing not done yet in upstream qiskit if hasattr(self._backend, "_conf_dict") and self._backend._conf_dict["open_pulse"]: if "u_channel_lo" not in self._backend._conf_dict: - self._backend._conf_dict["u_channel_lo"] = [] # to avoid terra bug + self._backend._conf_dict["u_channel_lo"] = [] # to avoid qiskit bug self._pulse_conf = PulseBackendConfiguration.from_dict(self._backend._conf_dict) @property @@ -222,7 +222,7 @@ def meas_freqs(self): .. note:: - The qiskit-terra base classes do not provide this information as a + The qiskit base classes do not provide this information as a standard backend property, but it is available from some providers in the data returned by the ``Backend.defaults()`` method. """ @@ -249,7 +249,7 @@ def is_simulator(self): For `BackendV2` we sometimes cannot be sure, because it lacks a `simulator` field, as was present in `BackendV1`'s configuration. We still check whether the backend inherits `FakeBackendV2`, for - either of its existing implementations in Terra. + either of its existing implementations in Qiskit. """ if self._v1: if self._backend.configuration().simulator or isinstance(self._backend, FakeBackend): diff --git a/qiskit_experiments/library/randomized_benchmarking/data/generate_clifford_data.py b/qiskit_experiments/library/randomized_benchmarking/data/generate_clifford_data.py index 5970e190b6..7ebd45dcab 100644 --- a/qiskit_experiments/library/randomized_benchmarking/data/generate_clifford_data.py +++ b/qiskit_experiments/library/randomized_benchmarking/data/generate_clifford_data.py @@ -16,8 +16,6 @@ The script relies on the values of ``_CLIFF_SINGLE_GATE_MAP_2Q`` in :mod:`~qiskit_experiment.library.randomized_benchmarking.clifford_utils` so they must be set correctly before running the script. - -Note: Terra >= 0.22 is required to run this script. """ import itertools diff --git a/test/framework/test_backend_timing.py b/test/framework/test_backend_timing.py index a4b64f4075..baaf2779f7 100644 --- a/test/framework/test_backend_timing.py +++ b/test/framework/test_backend_timing.py @@ -30,7 +30,7 @@ def setUpClass(cls): super().setUpClass() # Creating a complete fake backend is difficult so we use one from - # terra. Just to be safe, we check that the properties we care about + # qiskit. Just to be safe, we check that the properties we care about # for these tests are never changed from what the tests assume. backend = FakeNairobiV2() target = backend.target From e0a17a2214625597bd56f0543499ff3eba1e4f88 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 14:54:06 -0500 Subject: [PATCH 06/11] Remove unused imports --- qiskit_experiments/database_service/utils.py | 1 - test/framework/test_backend_timing.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/qiskit_experiments/database_service/utils.py b/qiskit_experiments/database_service/utils.py index 4a2fc68759..dab4b04f03 100644 --- a/qiskit_experiments/database_service/utils.py +++ b/qiskit_experiments/database_service/utils.py @@ -24,7 +24,6 @@ import json import dateutil.parser -import pkg_resources from dateutil import tz from qiskit_ibm_experiment import ( diff --git a/test/framework/test_backend_timing.py b/test/framework/test_backend_timing.py index baaf2779f7..c270795069 100644 --- a/test/framework/test_backend_timing.py +++ b/test/framework/test_backend_timing.py @@ -18,7 +18,7 @@ from qiskit import QiskitError from qiskit.providers.fake_provider import FakeNairobiV2 -from qiskit_experiments.framework import BackendData, BackendTiming +from qiskit_experiments.framework import BackendTiming @ddt From 35a8da8228f7f49fbc711432008bed2e23487bcf Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 14:55:56 -0500 Subject: [PATCH 07/11] Replace terra usage in tox.ini and GitHub workflows --- .github/workflows/cron-staging.yml | 10 +++++----- tox.ini | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cron-staging.yml b/.github/workflows/cron-staging.yml index 580fc00c73..844c7683f5 100644 --- a/.github/workflows/cron-staging.yml +++ b/.github/workflows/cron-staging.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: jobs: - terra-main-tests: + qiskit-main-tests: name: tests-python${{ matrix.python-version }}-${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: @@ -37,10 +37,10 @@ jobs: - name: Install Deps run: python -m pip install -U tox setuptools virtualenv wheel - name: Install and Run Tests (Windows and Linux) - run: tox -e terra-main + run: tox -e qiskit-main if: runner.os != 'macOS' - name: Install and Run Tests (Macs only) - run: tox -e terra-main + run: tox -e qiskit-main if: runner.os == 'macOS' env: TEST_TIMEOUT: 120 @@ -66,7 +66,7 @@ jobs: python -m pip install -U tox sudo apt-get install -y pandoc graphviz - name: Build Docs - run: tox -edocs-terra-main + run: tox -edocs-qiskit-main - name: Compress Artifacts run: | mkdir artifacts @@ -75,4 +75,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: html_docs - path: artifacts \ No newline at end of file + path: artifacts diff --git a/tox.ini b/tox.ini index c5b5f63af4..1392db4a83 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ commands = coverage3 combine coverage3 lcov -[testenv:terra-main] +[testenv:qiskit-main] usedevelop = True install_command = pip install -U {opts} {packages} setenv = @@ -106,7 +106,7 @@ setenv = commands = sphinx-build -T -W --keep-going -b html {posargs} docs/ docs/_build/html -[testenv:docs-terra-main] +[testenv:docs-qiskit-main] usedevelop = True passenv = EXPERIMENTS_DEV_DOCS From f94166ab252c451a110987e73bf89bd7e831e1f4 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 15:00:47 -0500 Subject: [PATCH 08/11] Typo --- releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml b/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml index cc5d5c561f..965a7cc7e7 100644 --- a/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml +++ b/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml @@ -2,7 +2,7 @@ upgrade: - | The dependency on ``qiskit-terra`` was replaced with a dependency on - ``qiskit``. This change follows move in upstream Qiskit to rename + ``qiskit``. This change follows the move in upstream Qiskit to rename ``qiskit-terra`` to ``qiskit``. For more information see `the Qiskit repository renaming plan `__ From bc4dd2229244e2c48b628204704f3777b7e0b91c Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 23:16:29 -0500 Subject: [PATCH 09/11] Log both qiskit and qiskit-experiments versions --- qiskit_experiments/database_service/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_experiments/database_service/utils.py b/qiskit_experiments/database_service/utils.py index dab4b04f03..928d3ac43b 100644 --- a/qiskit_experiments/database_service/utils.py +++ b/qiskit_experiments/database_service/utils.py @@ -38,7 +38,7 @@ def qiskit_version(): """Return the Qiskit version.""" - return importlib.metadata.distribution("qiskit").version + return {p: importlib.metadata.distribution(p).version for p in ("qiskit", "qiskit-experiments")} def parse_timestamp(utc_dt: Union[datetime, str]) -> datetime: From e42b0be8c7028a71f89c18fc7921054c67731a8d Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 23:18:27 -0500 Subject: [PATCH 10/11] Report the minimum required qiskit version in the release note --- releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml b/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml index 965a7cc7e7..f65061aaab 100644 --- a/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml +++ b/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml @@ -3,8 +3,10 @@ upgrade: - | The dependency on ``qiskit-terra`` was replaced with a dependency on ``qiskit``. This change follows the move in upstream Qiskit to rename - ``qiskit-terra`` to ``qiskit``. For more information see `the Qiskit - repository renaming plan + ``qiskit-terra`` to ``qiskit``. The minimum required version was increased + from 0.24 for ``qiskit-terra`` to 0.44 for ``qiskit`` (equivalent to + `qiskit-terra`` 0.25).For more information see `the Qiskit repository + renaming plan `__ and the `Qiskit issue `__ for the renaming of the package. From 6460bb66ce8fd34a838b5a8b76b1da4055dfb3d1 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Wed, 15 Nov 2023 23:19:08 -0500 Subject: [PATCH 11/11] Limit qiskit version to <1.0 --- releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml | 7 +++++-- requirements.txt | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml b/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml index f65061aaab..f2b29811b4 100644 --- a/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml +++ b/releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml @@ -5,8 +5,11 @@ upgrade: ``qiskit``. This change follows the move in upstream Qiskit to rename ``qiskit-terra`` to ``qiskit``. The minimum required version was increased from 0.24 for ``qiskit-terra`` to 0.44 for ``qiskit`` (equivalent to - `qiskit-terra`` 0.25).For more information see `the Qiskit repository - renaming plan + `qiskit-terra`` 0.25). The maximum ``qiskit`` version was set to ``<1.0`` + in anticipation of breaking changes in Qiskit 1.0. Closer to the Qiskit 1.0 + release, a patch release of ``qiskit-experiments`` will remove this + constraint and address any compatibility issues. For more information see + the `Qiskit repository renaming plan `__ and the `Qiskit issue `__ for the renaming of the package. diff --git a/requirements.txt b/requirements.txt index 20f645b1a8..3eccafd64d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ numpy>=1.17 scipy>=1.4 -qiskit>=0.44 +qiskit>=0.44,<1.0 qiskit-ibm-experiment>=0.3.4 matplotlib>=3.4 uncertainties