Skip to content

Commit

Permalink
Add optional dependencies file (#1219)
Browse files Browse the repository at this point in the history
### Summary

This PR adds `requirements-extras.txt` which contains extra packages
that can be installed as `[extras]` and were mostly moved from
`requirements-dev.txt`. These are in contrast to the core dependencies
in `requirements.txt` and the requirements that are only used for tests,
which will stay in `requirements-dev.txt`.

### Details and comments

While the optional packages are not related to each other, it seemed too
complicated to split out optional dependencies into further categories.

There are a few additional changes:

- Added `qiskit-ibm-provider>=0.6.1` as an optional dependency since
this release adds numpy serialization, which fixes some known bugs with
circuit metadata serialization (see also #1176)
- Unpinned `scipy` (done in #1164) and bumped `cvxpy` to 1.3.2, which is
now compatible with scipy 1.11
- Removed matrix variables from CI workflow that doesn't use them
- Updated install and contributing instructions
  • Loading branch information
coruscating authored Jul 19, 2023
1 parent d9a767b commit f4c8686
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cron-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-tests-${{ hashFiles('setup.py','requirements.txt','requirements-dev.txt','constraints.txt') }}
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-tests-${{ hashFiles('setup.py','requirements.txt','requirements-extras.txt','requirements-dev.txt','constraints.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-tests-
${{ runner.os }}-${{ matrix.python-version }}-pip-
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-tests-${{ hashFiles('setup.py','requirements.txt','requirements-dev.txt','constraints.txt') }}
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-tests-${{ hashFiles('setup.py','requirements.txt','requirements-extras.txt','requirements-dev.txt','constraints.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-tests-
${{ runner.os }}-${{ matrix.python-version }}-pip-
Expand Down Expand Up @@ -72,11 +72,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-lint-${{ hashFiles('setup.py','requirements.txt','requirements-dev.txt','constraints.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-lint-
${{ runner.os }}-${{ matrix.python-version }}-pip-
${{ runner.os }}-${{ matrix.python-version }}-
key: ${{ runner.os }}-pip-lint-${{ hashFiles('setup.py','requirements.txt','requirements-extras.txt','requirements-dev.txt','constraints.txt') }}
- name: Install Deps
run: python -m pip install -U tox
- name: Run lint
Expand All @@ -96,11 +92,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-docs-${{ hashFiles('setup.py','requirements.txt','requirements-dev.txt','constraints.txt') }}
restore-keys: |
${{ runner.os }}-pip-docs-
${{ runner.os }}-pip-
${{ runner.os }}-
key: ${{ runner.os }}-pip-docs-${{ hashFiles('setup.py','requirements.txt','requirements-extras.txt','requirements-dev.txt','constraints.txt') }}
- name: Install Deps
run: |
python -m pip install -U tox
Expand Down
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ When submitting a pull request for review, please ensure that:
5. If your change has an end user facing impact (new feature, deprecation, removal,
etc.), you've added or updated a reno release note for that change and tagged the PR
for the changelog.
6. If your code requires a change to dependencies, you've updated the corresponding
requirements file: `requirements.txt` contain core dependencies,
`requirements-extras.txt` for dependencies for optional features, and `requirements-dev.txt`
for dependencies required for running tests and building documentation.

The sections below go into more detail on the guidelines for each point.

Expand Down Expand Up @@ -341,8 +345,8 @@ https://github.com/Qiskit-Extensions/qiskit-experiments` and `git fetch upstream

There are a few other build options available:

* `tox -edocs-minimal`: build documentation without executing Jupyter code cells
* `tox -edocs-parallel`: do a full build with multiprocessing (may crash on Macs)
* `tox -e docs-minimal`: build documentation without executing Jupyter code cells
* `tox -e docs-parallel`: do a full build with multiprocessing (may crash on Macs)

### Deprecation policy

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include LICENSE.txt
include requirements.txt
include requirements-extras.txt
include qiskit_experiments/VERSION.txt
include qiskit_experiments/library/randomized_benchmarking/data/*.npz
exclude qiskit_experiments/library/randomized_benchmarking/data/generate_clifford_data.py
4 changes: 4 additions & 0 deletions docs/tutorials/calibrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ This automatic updating can also be disabled using the ``auto_update`` flag.
This tutorial requires the :mod:`qiskit_dynamics` package to run simulations.
You can install it with ``python -m pip install qiskit-dynamics``.

.. note::
This tutorial requires the ``pandas`` package to visualize calibration tables.
You can install it with ``python -m pip install pandas``.

.. jupyter-execute::

import pandas as pd
Expand Down
9 changes: 8 additions & 1 deletion docs/tutorials/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ in your shell environment:
python -m pip install qiskit-experiments
There are a number of optional packages that enable some experiments and features. If you
would like to install these optional dependencies, run:

.. code-block::
python -m pip install "qiskit-experiments[extras]"
If you want to run the most up-to-date version instead (may not be stable), you can
install the latest main branch:

Expand All @@ -30,7 +37,7 @@ cloning the repository:
.. code-block::
git clone https://github.com/Qiskit-Extensions/qiskit-experiments.git
python -m pip install -e qiskit-experiments
python -m pip install -e "qiskit-experiments[extras]"
The ``-e`` option will keep your installed package up to date as you make or pull new
changes.
Expand Down
1 change: 0 additions & 1 deletion qiskit_experiments/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
MockIQParallelBackend
T2HahnBackend
NoisyDelayAerBackend
PulseBackend
SingleTransmonTestBackend
Helpers
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/requirements-extras-d5768794acbce467.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
other:
- |
A new set of optional dependencies have been split off from the developer dependencies and
can be installed separately as ``qiskit-experiments[extras]``. These are packages that enable
optional experiment features such as ``scikit-learn``-based discriminators.
4 changes: 0 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ reno>=4.0.0
nbsphinx
arxiv
ddt>=1.6.0
qiskit-aer>=0.11.0
qiskit_dynamics>=0.4.0
pandas>=1.1.5
cvxpy>=1.1.15
pylatexenc
multimethod
scikit-learn
sphinx-copybutton
coverage>=5.5
# Pin versions below because of build errors
Expand Down
5 changes: 5 additions & 0 deletions requirements-extras.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
qiskit-ibm-provider>=0.6.1 # for submitting experiments to backends through the IBM provider
cvxpy>=1.3.2 # for tomography
scikit-learn # for discriminators
qiskit-aer>=0.11.0 # for QV simulations
qiskit_dynamics>=0.4.0 # for the PulseBackend
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
numpy>=1.17
# temporary maximum version limit due to cvxpy incompatibility
# see https://github.com/cvxpy/cvxpy/issues/2158
scipy>=1.4,<1.11.0
scipy>=1.4
qiskit-terra>=0.24
qiskit-ibm-experiment>=0.3.3
matplotlib>=3.4
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
with open("requirements.txt", encoding="utf-8") as f:
REQUIREMENTS = f.read().splitlines()

with open("requirements-extras.txt", encoding="utf-8") as f:
EXTRAS = f.read().splitlines()

version_path = os.path.abspath(
os.path.join(os.path.join(os.path.dirname(__file__), "qiskit_experiments"), "VERSION.txt")
Expand Down Expand Up @@ -58,6 +60,7 @@
keywords="qiskit sdk quantum",
packages=find_packages(exclude=["test*"]),
install_requires=REQUIREMENTS,
extras_require={"extras": EXTRAS},
include_package_data=True,
python_requires=">=3.8",
project_urls={
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ install_command = pip install -c{toxinidir}/constraints.txt -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
QISKIT_SUPPRESS_PACKAGING_WARNINGS=Y
deps = -r{toxinidir}/requirements-dev.txt
deps =
-r{toxinidir}/requirements-dev.txt
-r{toxinidir}/requirements-extras.txt
passenv =
OMP_NUM_THREADS
QISKIT_PARALLEL
Expand All @@ -36,6 +38,7 @@ setenv =
deps =
git+https://github.com/Qiskit/qiskit-terra
-r{toxinidir}/requirements-dev.txt
-r{toxinidir}/requirements-extras.txt
passenv =
OMP_NUM_THREADS
QISKIT_PARALLEL
Expand Down

0 comments on commit f4c8686

Please sign in to comment.