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

Replace qiskit-terra references with qiskit references #1318

Merged
merged 11 commits into from
Nov 16, 2023
10 changes: 5 additions & 5 deletions .github/workflows/cron-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -75,4 +75,4 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: html_docs
path: artifacts
path: artifacts
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
4 changes: 2 additions & 2 deletions constraints.txt
Original file line number Diff line number Diff line change
@@ -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
numpy<1.25
10 changes: 2 additions & 8 deletions qiskit_experiments/database_service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

"""Experiment utility functions."""

import importlib.metadata
import io
import logging
import threading
Expand All @@ -23,28 +24,21 @@
import json

import dateutil.parser
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not also return the Qiskit Experiments version like the previous code did in the except clause? I'm not quite sure what this function is meant for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a little confused by this part. Qiskit is a required dependency, so we should be able to get its version without error and not need the except block, so I went with what the try block was doing to continue the existing behavior. I pushed a new commit to switch to the except block style of capturing qiskit and qiskit-experiments. I thought about capturing other packages (qiskit-ibm-experiment?) but I think these two make the most sense. qiskit changes could change transpilation and affect the circuits in something like RB. qiskit-experiments could change the circuits method or the analysis function. So it is good to capture both with the experiment metadata.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, saving both makes sense and we probably should have been doing that earlier. We may have to change this to git commit IDs in the future but this is good for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. I had been thinking about that. I have done it on other repos before.



def parse_timestamp(utc_dt: Union[datetime, str]) -> datetime:
Expand Down
13 changes: 5 additions & 8 deletions qiskit_experiments/framework/backend_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -225,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.
"""
Expand All @@ -252,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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions releasenotes/notes/qiskit-dependency-3f6b8d71cc4d2c31.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
upgrade:
- |
The dependency on ``qiskit-terra`` was replaced with a dependency on
``qiskit``. This change follows the move in upstream Qiskit to rename
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the old and new version numbers be explicitly mentioned here too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done but we need to keep this release note in mind if we merge #1288 and increase the minimum qiskit version.

``qiskit-terra`` to ``qiskit``. For more information see `the Qiskit
repository renaming plan
<https://github.com/Qiskit/RFCs/blob/5793e78dc8e4d8d17f8ef7fad789c6c5ebd3a061/0011-repo-rename.md>`__
and the `Qiskit issue <https://github.com/Qiskit/qiskit/issues/11240>`__
for the renaming of the package.
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qiskit-terra>=0.45.0
qiskit>=0.45.0
black~=22.0
fixtures
stestr
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 4 additions & 7 deletions test/framework/test_backend_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,24 +30,21 @@ 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()
# 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
)
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
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ commands =
coverage3 combine
coverage3 lcov

[testenv:terra-main]
[testenv:qiskit-main]
usedevelop = True
install_command = pip install -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
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 =
Expand Down Expand Up @@ -106,15 +106,15 @@ 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
PROD_BUILD
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 =
Expand Down