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 no-optionals and full-optionals test runs #8967

Merged
merged 53 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a66534b
Add no-optionals and full-optionals test runs
jakelishman Oct 20, 2022
a74b00d
Fix typo in coverage workflow
jakelishman Oct 20, 2022
5cbaa18
Try relaxing ipython constraints
jakelishman Oct 20, 2022
69efa6b
Merge branch 'main' into test-all-optionals
jakelishman Oct 21, 2022
d6f9f0c
Squash newly exposed lint failures
jakelishman Oct 25, 2022
a5c009a
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Oct 25, 2022
69b4169
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Oct 28, 2022
96bb7c6
Fix typo in tutorials pipeline
jakelishman Oct 28, 2022
69a6613
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Nov 21, 2022
80c5945
Update the 'also update' comments
jakelishman Nov 22, 2022
535f270
Remove unneeded qiskit-toqm dependency
jakelishman Nov 22, 2022
8f84190
Section requirements-optional.txt
jakelishman Nov 22, 2022
df6c788
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Nov 22, 2022
75b3843
Test all optionals on min not max Python version
jakelishman Dec 2, 2022
093f3ce
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Dec 2, 2022
6f25dae
Add missing test skip
jakelishman Dec 2, 2022
ce7eb62
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Dec 2, 2022
6a87fba
Fix optional call
jakelishman Dec 2, 2022
abaf410
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Mar 24, 2023
5aff793
Use correct boolean syntax
jakelishman Mar 24, 2023
a070912
Fix tests relying on Jupyter
jakelishman Mar 24, 2023
dc4f7b7
Install ipykernel in tutorials
jakelishman Mar 24, 2023
7bdc4e6
Remove HAS_PDFLATEX skip from quantum_info tests
jakelishman Mar 24, 2023
c458f35
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Mar 24, 2023
d885c9f
Include additional tutorials dependencies
jakelishman Mar 24, 2023
ba18634
Install all of Terra's optionals in tutorial run
jakelishman Mar 24, 2023
73e8e81
Do not install all optionals in docs build
jakelishman Mar 27, 2023
e3f835b
Use class-level skips where appropriate
jakelishman Mar 27, 2023
b558eb6
Do not install ibmq-provider in tutorials run
jakelishman Mar 27, 2023
074eb1f
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Mar 27, 2023
8946ac1
Include matplotlib in docs requirements
jakelishman Mar 27, 2023
c5fbab1
Remove unnecessary whitespace
jakelishman Mar 30, 2023
b3e283d
Split long pip line
jakelishman Mar 30, 2023
e281017
Only install graphviz when installOptionals
jakelishman Mar 30, 2023
9b49456
Install visualization extras in docs build
jakelishman Mar 30, 2023
2da5f2a
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Mar 30, 2023
acfe227
Don't `--upgrade` when installing optionals
jakelishman Mar 30, 2023
3017603
Update secondary installation of Terra in docs build
jakelishman Mar 30, 2023
3c82457
Install all optionals during the docs build
jakelishman Mar 30, 2023
286ffb9
Fix test setup job
jakelishman Mar 31, 2023
681e2fd
Remove duplication of matplotlib in requirements files
jakelishman Mar 31, 2023
9310fc8
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Mar 31, 2023
49b07a3
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Apr 21, 2023
bd37cb9
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman May 25, 2023
1b77b10
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Jul 11, 2023
ab254a7
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Jul 11, 2023
981c6b5
Update image test installation command
jakelishman Jul 11, 2023
2469e97
Restore editable build
jakelishman Jul 11, 2023
2679adf
Merge remote-tracking branch 'ibm/main' into test-all-optionals
jakelishman Jul 18, 2023
67682df
Move `pip check` to `pip` section
jakelishman Jul 19, 2023
f9b5cba
Remove redundant "post-install" description
jakelishman Jul 19, 2023
4c0a986
Expand comment on first-stage choices
jakelishman Jul 19, 2023
db06df9
pytohn lol
jakelishman Jul 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions .azure/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ parameters:
- name: "testImages"
type: boolean

- name: "installOptionals"
type: boolean
default: false

- name: "installFromSdist"
type: boolean
default: false
Expand Down Expand Up @@ -84,27 +88,27 @@ jobs:
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"

- ${{ if eq(parameters.installOptionals, true) }}:
- bash: |
set -e
source test-job/bin/activate
python -m pip install -r requirements-optional.txt -c constraints.txt
python -m pip check
displayName: "Install optional packages"

- bash: |
set -e
sudo apt-get update
sudo apt-get install -y graphviz
displayName: 'Install optional non-Python dependencies'

- bash: |
set -e
source test-job/bin/activate
python -m pip install -U \
-c constraints.txt \
"cplex ; python_version < '3.11'" \
"qiskit-aer" \
"tweedledum ; python_version < '3.11'" \
"z3-solver"
mkdir -p /tmp/terra-tests
cp -r test /tmp/terra-tests/.
cp .stestr.conf /tmp/terra-tests/.
cp -r .stestr /tmp/terra-tests/. || :
sudo apt-get update
sudo apt-get install -y graphviz
pip check
displayName: 'Install post-install optional dependencies'

- bash: |
set -e
source test-job/bin/activate
pushd /tmp/terra-tests
export PYTHONHASHSEED=$(python -S -c "import random; print(random.randint(1, 4294967295))")
echo "PYTHONHASHSEED=$PYTHONHASHSEED"
Expand Down Expand Up @@ -178,7 +182,8 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
-e ".[visualization]"
-r requirements-optional.txt \
-e .
sudo apt-get update
sudo apt-get install -y graphviz pandoc
image_tests/bin/pip check
Expand Down
11 changes: 11 additions & 0 deletions .azure/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ parameters:
type: string
displayName: "Version of Python to test"

- name: "installOptionals"
type: boolean
default: false

jobs:
- job: "MacOS_Tests_Python${{ replace(parameters.pythonVersion, '.', '') }}"
displayName: "Test macOS Python ${{ parameters.pythonVersion }}"
Expand Down Expand Up @@ -45,6 +49,13 @@ jobs:
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"

- ${{ if eq(parameters.installOptionals, true) }}:
- bash: |
set -e
source test-job/bin/activate
pip install -r requirements-optional.txt -c constraints.txt
displayName: "Install optional packages"

- bash: |
set -e
source test-job/bin/activate
Expand Down
13 changes: 12 additions & 1 deletion .azure/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ parameters:
type: string
displayName: "Versions of Python to test"

- name: "installOptionals"
type: boolean
default: false

jobs:
- job: "Windows_Tests_Python${{ replace(parameters.pythonVersion, '.', '') }}"
displayName: "Test Windows Python ${{ parameters.pythonVersion }}"
Expand Down Expand Up @@ -38,13 +42,20 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
"z3-solver" \
-e .
pip check
displayName: 'Install dependencies'
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"

- ${{ if eq(parameters.installOptionals, true) }}:
- bash: |
set -e
source test-job/Scripts/activate
pip install -c constraints.txt -r requirements-optional.txt
pip check
displayName: "Install optional packages"

- bash: |
set -e
chcp.com 65001
Expand Down
12 changes: 2 additions & 10 deletions .azure/tutorials-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,8 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
"qiskit-ibmq-provider" \
"qiskit-aer" \
"z3-solver" \
"networkx" \
"matplotlib>=3.3.0" \
sphinx \
nbsphinx \
sphinx_rtd_theme \
"tweedledum ; python_version < '3.11'" \
cvxpy \
-r requirements-optional.txt \
-r requirements-tutorials.txt \
-e .
sudo apt-get update
sudo apt-get install -y graphviz pandoc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Generate unittest coverage report
run: |
set -e
python -m pip install -c constraints.txt -r requirements-dev.txt qiskit-aer
python -m pip install -c constraints.txt -r requirements-dev.txt -r requirements-optional.txt
stestr run
# We set the --source-dir to '.' because we want all paths to appear relative to the repo
# root (we need to combine them with the Python ones), but we only care about `grcov`
Expand Down
19 changes: 17 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,17 @@ stages:
testQPY: false
testImages: false
testRust: false
installOptionals: true

- template: ".azure/test-macos.yml"
parameters:
pythonVersion: ${{ version }}
installOptionals: true

- template: ".azure/test-windows.yml"
parameters:
pythonVersion: ${{ version }}
installOptionals: true

- stage: "Nightly_Failure"
displayName: "Comment on nightly failure"
Expand Down Expand Up @@ -150,9 +153,15 @@ stages:
- template: ".azure/test-linux.yml"
parameters:
pythonVersion: ${{ parameters.minimumPythonVersion }}
# A PR is more likely to fail CI because it introduces a logic error
# into an existing test than because it adds a new test / optional
# dependency that isn't accounted for in the test-skipping logic
# (and such a failure would need fewer iterations to fix). We want
# to fail fast in the first CI stage.
installOptionals: true
testRust: true
testQPY: true
testImages: false
testImages: true

# The rest of the PR pipeline is to test the oldest and newest supported
# versions of Python, along with the integration tests (via the tutorials).
Expand All @@ -172,24 +181,29 @@ stages:
pythonVersion: ${{ parameters.maximumPythonVersion }}
testRust: false
testQPY: false
testImages: true
testImages: false
installFromSdist: true
installOptionals: false
Copy link
Member

Choose a reason for hiding this comment

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

One mild concern I have here is when we're adding support for a new python version it might be harder to know when our optional extras support it with this since we're only running the old side with the optional extras. That being said I think we should be ok to try this to start and we'll see how it goes for Python 3.12 support.

Copy link
Member Author

Choose a reason for hiding this comment

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

I set the cronjob CI to use the full optionals, so we'll find out from the nightly run whether stuff works or not without blocking CI.


- template: ".azure/test-macos.yml"
parameters:
pythonVersion: ${{ parameters.minimumPythonVersion }}
installOptionals: true

- template: ".azure/test-macos.yml"
parameters:
pythonVersion: ${{ parameters.maximumPythonVersion }}
installOptionals: false

- template: ".azure/test-windows.yml"
parameters:
pythonVersion: ${{ parameters.minimumPythonVersion }}
installOptionals: true

- template: ".azure/test-windows.yml"
parameters:
pythonVersion: ${{ parameters.maximumPythonVersion }}
installOptionals: false

# Push to main or the stable branches. The triggering branches also need to
# be in the triggers at the top of this file.
Expand All @@ -202,6 +216,7 @@ stages:
testRust: true
testQPY: true
testImages: true
installOptionals: false

# Push to a tag. The triggering tags are set in the triggers at the top of
# this file.
Expand Down
2 changes: 2 additions & 0 deletions qiskit/transpiler/passes/layout/_csp_custom_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
class CustomSolver(RecursiveBacktrackingSolver):
"""A wrap to RecursiveBacktrackingSolver to support ``call_limit``"""

# pylint: disable=invalid-name

def __init__(self, call_limit=None, time_limit=None):
self.call_limit = call_limit
self.time_limit = time_limit
Expand Down
8 changes: 8 additions & 0 deletions qiskit/utils/optionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
- Some methods of gradient calculation within :mod:`.opflow.gradients` require `JAX
<https://github.com/google/jax>`__ for autodifferentiation.

* - .. py:data:: HAS_JUPYTER
- Some of the tests require a complete `Jupyter <https://jupyter.org/>`__ installation to test
interactivity features.

* - .. py:data:: HAS_MATPLOTLIB
- Qiskit Terra provides several visualisation tools in the :mod:`.visualization` module.
Almost all of these are built using `Matplotlib <https://matplotlib.org/>`__, which must
Expand Down Expand Up @@ -205,6 +209,9 @@
.. autoclass:: qiskit.utils.LazySubprocessTester
"""

# NOTE: If you're changing this file, sync it with `requirements-optional.txt` and potentially
# `setup.py` as well.

import logging as _logging

from .lazy_tester import (
Expand Down Expand Up @@ -256,6 +263,7 @@
name="jax",
install="pip install jax",
)
HAS_JUPYTER = _LazyImportTester(["jupyter", "nbformat", "nbconvert"], install="pip install jupyter")
HAS_MATPLOTLIB = _LazyImportTester(
("matplotlib.patches", "matplotlib.pyplot"),
name="matplotlib",
Expand Down
2 changes: 2 additions & 0 deletions qiskit/visualization/bloch.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
class Arrow3D(Patch3D, FancyArrowPatch):
"""Makes a fancy arrow"""

# pylint: disable=missing-function-docstring,invalid-name

# Nasty hack around a poorly implemented deprecation warning in Matplotlib 3.5 that issues two
# deprecation warnings if an artist's module does not claim to be part of the below module.
# This revolves around the method `Patch3D.do_3d_projection(self, renderer=None)`. The
Expand Down
47 changes: 28 additions & 19 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
coverage>=4.4.0,<7.0
hypothesis>=4.24.3
python-constraint>=1.4
ipython<7.22.0
ipykernel<5.5.2
ipywidgets>=7.3.0
jupyter
matplotlib>=3.3
pillow>=4.2.1
# Requirements to develop Terra, and the minimum needed to run its CI. All
# optional requirements should go in `requirements-optionals.txt` instead.
#
# Version requirements here can be more restrictive than elsewhere, because they
# never become actual package requirements, but still try to be as relaxed as
# possible so it's easy to develop multiple packages from the same venv.

# Style
black[jupyter]~=22.0
pydot


# Lint
#
# These versions are pinned precisely because pylint frequently includes new
# on-by-default lint failures in new versions, which breaks our CI.
astroid==2.14.2
pylint==2.16.2
ruff==0.0.267


# Tests
coverage>=4.4.0
hypothesis>=4.24.3
stestr>=2.0.0,!=4.0.0
pylatexenc>=1.4
ddt>=1.2.0,!=1.4.0,!=1.4.3
seaborn>=0.9.0


# Documentation tooling.
#
# This alone is not sufficient to fully build the documentation, because several
# components of Terra use some of its optional dependencies in order to document
# themselves. These are the requirements that are _only_ required for the docs
# build, and are not used by Terra itself.

# TODO: switch to stable release when 4.1 is released
reno @ git+https://github.com/openstack/reno.git@81587f616f17904336cdc431e25c42b46cd75b8f
Sphinx>=5.0
qiskit-sphinx-theme~=1.11.0
sphinx-design>=0.2.0
pygments>=2.4
scikit-learn>=0.20.0
scikit-quant<=0.7;platform_system != 'Windows'
jax;platform_system != 'Windows'
jaxlib;platform_system != 'Windows'
docplex
qiskit-qasm3-import
40 changes: 40 additions & 0 deletions requirements-optional.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Optional dependencies of Terra that can (mostly) reliably be installed with
# `pip`. This file is still called `requirements-optional.txt` just to match
# standard pip conventions, even though none of these are required.
#
# If updating this, you probably want to update `qiskit.utils.optionals` and
# maybe `setup.py` too.

# Test-runner enhancements.
fixtures
mtreinish marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any downside to installing fixtures and testtools in requirements-dev.txt? Presumably those are helpful when locally running tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

There historically was a reason, particularly for testtools, but I don't remember what it was now. Matthew (@mtreinish) will know.

Copy link
Member

@mtreinish mtreinish Apr 7, 2023

Choose a reason for hiding this comment

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

There were two historical reasons for it. First there was a time when there was an incompatibility with some skip decorators between testtools and unittest on newer python versions, but I believe we fixed that in the testtools 2.5.0 release. The second and larger reason was for people that wanted to just run with unittest. The only thing we use testtools for is to wrap unittest and leverage testtools' result stream feature. That lets us attach captured stdout, stderr, and python logging and have that associated with an individual test. The issue was historically there are people who don't like running with stestr and prefer using make test to use the stdlib python unittest runner. If we used testtools' stdout, stderr, and logging capture fixtures then that would hide any stdout from tests for people using the stdlib runner. But that should have also been sorted long ago by adding an env variable to enable to the capture.

TBH, this was mostly the result of a historical compromise from when we first started using stestr for qiskit back in 2018/2019. Back then some others felt very strongly that people should be able to run the tests without installing an extra test runner package (neglecting that you needed a bunch of different libraries to even install qiskit, let alone run the tests). So when we started using stestr by default for the improved throughput it provided we made sure there was a path for those who didn't want to abandon the stdlib runner.

That being said 4-5 yrs later I'm not sure this really matters anymore. I think in a follow up we should just move it into the requirements list and see what happens. I would expect anyone still using make test (despite the warnings it prints about using tox instead) should still have the same experience.

testtools
jupyter

# Interactivity.
ipykernel
ipython
ipywidgets>=7.3.0
matplotlib>=3.3
pillow>=4.2.1
pydot
pygments>=2.4
pylatexenc>=1.4
seaborn>=0.9.0

# Functionality and accelerators.
qiskit-aer
qiskit-qasm3-import
python-constraint>=1.4
cplex; python_version < '3.11'
cvxpy
docplex
jax; platform_system != 'Windows'
jaxlib; platform_system != 'Windows'
scikit-learn>=0.20.0
scikit-quant<=0.7; platform_system != 'Windows'
SQSnobFit
z3-solver>=4.7
# Tweedledum is unmaintained and its existing Mac wheels are unreliable. If you
# manage to get a working install on a Mac the functionality should still work,
# but as a convenience this file won't attempt the install itself.
tweedledum; python_version<'3.11' and platform_system!="Darwin"
10 changes: 10 additions & 0 deletions requirements-tutorials.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Requirements for the tutorials CI run that go beyond the others in `requirements-optional.txt`.
# This may also include some requirements that are only in `requirements-dev.txt`, since those
# aren't runtime dependencies or optionals of Terra.

networkx>=2.2
jupyter
Sphinx
nbsphinx
qiskit_sphinx_theme
pyscf
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
flags=re.S | re.M,
)


# If RUST_DEBUG is set, force compiling in debug mode. Else, use the default behavior of whether
# it's an editable installation.
rust_debug = True if os.getenv("RUST_DEBUG") == "1" else None


# If modifying these optional extras, make sure to sync with `requirements-optional.txt` and
# `qiskit.utils.optionals` as well.
qasm3_import_extras = [
"qiskit-qasm3-import>=0.1.0",
]
Expand Down
Loading