Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Qiskit/qiskit-terra into small_chan…
Browse files Browse the repository at this point in the history
…ge_docs/3
  • Loading branch information
1ucian0 committed Aug 7, 2023
2 parents de1ff79 + 0438a4b commit e202f57
Show file tree
Hide file tree
Showing 28 changed files with 210 additions and 77 deletions.
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

- 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
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

0 comments on commit e202f57

Please sign in to comment.