Skip to content

Commit

Permalink
merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
rupeshknn committed Dec 11, 2023
2 parents 922a68b + 8cc20df commit e00ecbc
Show file tree
Hide file tree
Showing 154 changed files with 2,991 additions and 1,586 deletions.
46 changes: 39 additions & 7 deletions .github/workflows/cron-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
workflow_dispatch:

jobs:
terra-main-tests:
qiskit-main-tests:
name: tests-python${{ matrix.python-version }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, "3.11"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
steps:
- name: Print Concurrency Group
Expand All @@ -36,11 +36,43 @@ jobs:
${{ runner.os }}-${{ matrix.python-version }}
- name: Install Deps
run: python -m pip install -U tox setuptools virtualenv wheel
- name: Install and Run Tests
run: tox -e terra-main
- name: Install and Run Tests (Windows and Linux)
run: tox -e qiskit-main
if: runner.os != 'macOS'
- name: Install and Run Tests
run: tox -e terra-main
- name: Install and Run Tests (Macs only)
run: tox -e qiskit-main
if: runner.os == 'macOS'
env:
OMP_NUM_THREADS: 1
TEST_TIMEOUT: 120
OMP_NUM_THREADS: 1
docs:
name: docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
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
sudo apt-get install -y pandoc graphviz
- name: Build Docs
run: tox -edocs-qiskit-main
- name: Compress Artifacts
run: |
mkdir artifacts
tar -Jcvf html_docs.tar.xz docs/_build/html
mv html_docs.tar.xz artifacts/.
- uses: actions/upload-artifact@v3
with:
name: html_docs
path: artifacts
26 changes: 14 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, "3.11"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
steps:
- name: Print Concurrency Group
Expand All @@ -39,25 +39,27 @@ jobs:
${{ runner.os }}-${{ matrix.python-version }}-pip-tests-
${{ runner.os }}-${{ matrix.python-version }}-pip-
${{ runner.os }}-${{ matrix.python-version }}
- name: Stestr cache
uses: actions/cache@v3
with:
path: .stestr
key: stestr-${{ runner.os }}-${{ matrix.python-version }}
restore-keys: |
stestr-${{ runner.os }}-
stestr-
- name: Install Deps
run: python -m pip install -U "tox==3.27.1" setuptools virtualenv wheel
run: python -m pip install -U tox setuptools virtualenv wheel stestr
- name: Install and Run Tests (Windows and Linux)
run: tox -e py
if: runner.os != 'macOS'
- name: Install and Run Tests (Macs only)
run: tox -e cover
run: tox -e py
if: runner.os == 'macOS'
env:
TEST_TIMEOUT: 120
OMP_NUM_THREADS: 1
- name: Report coverage to coveralls.io (Macs only)
if: runner.os == 'macOS'
uses: coverallsapp/github-action@v2
env:
ACTIONS_RUNNER_DEBUG: 1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: unit-tests_python${{ matrix.python-version }}-${{ matrix.os }}
path-to-lcov: coverage.lcov
- name: Clean up stestr cache
run: stestr history remove all

lint:
name: lint
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ jobs:
wheel-build:
name: Build and Publish Release Artifacts
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
- name: Install Deps
run: pip install -U twine wheel
run: pip install -U wheel
- name: Build Artifacts
run: |
python setup.py sdist
Expand All @@ -24,7 +27,4 @@ jobs:
with:
path: ./dist/qiskit*
- name: Publish to PyPi
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_USERNAME: qiskit
run: twine upload dist/qiskit*
uses: pypa/gh-action-pypi-publish@release/v1
5 changes: 4 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ disable=fixme, # disabled as TODOs would show up as warnings
no-else-return, # relax "elif" after a clause with a return
docstring-first-line-empty, # relax docstring style
import-outside-toplevel,
assigning-non-slot # https://github.com/Qiskit/qiskit-terra/pull/7347#issuecomment-985007311
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/pull/7347#issuecomment-985007311



Expand Down
1 change: 1 addition & 0 deletions .stestr.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[DEFAULT]
test_path=./test
parallel_class=True
30 changes: 20 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,27 +104,25 @@ https://stestr.readthedocs.io/en/stable/MANUAL.html#test-selection
If you want to run a single test module, test class, or individual test method you can
do this faster with the `-n`/`--no-discover` option. For example, to run a module:
```
tox -- -n test.python.test_examples
tox -epy310 -- -n test.framework.test_composite
```
Or to run the same module by path:

```
tox -- -n test/python/test_examples.py
```
To run a class:

```
tox -- -n test.python.test_examples.TestPythonExamples
tox -epy310 -- -n test.framework.test_composite.TestCompositeExperimentData
```

To run a method:
```
tox -- -n test.python.test_examples.TestPythonExamples.test_all_examples
tox -epy310 -- -n test.framework.test_composite.TestCompositeExperimentData.test_composite_save_load
```

Note that tests will fail automatically if they do not finish execution within 60 seconds.

#### STDOUT/STDERR and logging capture

When running tests in parallel using `stestr` either via tox, the Makefile (`make
test_ci`), or in CI, we set the env variable `QISKIT_TEST_CAPTURE_STREAMS`, which will
When running tests in parallel using `stestr` either via tox
or in CI, we set the env variable `QISKIT_TEST_CAPTURE_STREAMS`, which will
capture any text written to stdout, stderr, and log messages and add them as attachments
to the tests run so output can be associated with the test case it originated from.
However, if you run tests with `stestr` outside of these mechanisms, by default the
Expand All @@ -136,6 +134,18 @@ stdlib unittest runner, a similar result can be accomplished by using the
[`--buffer`](https://docs.python.org/3/library/unittest.html#command-line-options)
option (e.g. `python -m unittest discover --buffer ./test/python`).

#### Other testing related settings

The test code defines some environment variables that may occasionally be useful to set:

+ `TEST_TIMEOUT`: An integer representing the maximum time a test can take
before it is considered a failure.
+ `QE_USE_TESTTOOLS`: Set this variable to `FALSE`, `0`, or `NO` to have the
tests use `unittest.TestCase` as the base class. Otherwise, the default is
`testtools.TestCase` which is an extension of `unittest.TestCase`. In some
situations, a developer may wish to use a workflow that is not compatible with
the `testtools` extensions.

### Code style

The qiskit-experiments repository uses `black` for code formatting and style and
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![License](https://img.shields.io/github/license/Qiskit-Extensions/qiskit-experiments.svg)](https://opensource.org/licenses/Apache-2.0)
[![Release](https://img.shields.io/github/release/Qiskit-Extensions/qiskit-experiments.svg)](https://github.com/Qiskit-Extensions/qiskit-experiments/releases)
![Python](https://img.shields.io/pypi/pyversions/qiskit-experiments.svg)
[![Coverage Status](https://coveralls.io/repos/github/Qiskit-Extensions/qiskit-experiments/badge.svg?branch=main)](https://coveralls.io/github/Qiskit-Extensions/qiskit-experiments?branch=main)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.05329/status.svg)](https://doi.org/10.21105/joss.05329)

**Qiskit Experiments** is a repository that builds tools for building, running,
Expand Down
4 changes: 0 additions & 4 deletions constraints.txt
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
# Numpy 1.25 deprecated some behaviours that we used, and caused some
# tests to flake. See https://github.com/Qiskit/qiskit-terra/issues/10305,
# remove pin when resolving that.
numpy<1.25
4 changes: 2 additions & 2 deletions docs/_ext/custom_styles/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def format_header(self, lines: List[str]) -> List[str]:
def format_overview(self, lines: List[str]) -> List[str]:
"""Format overview section."""
format_lines = [
""
"",
".. rubric:: Overview",
"",
]
Expand Down Expand Up @@ -167,7 +167,7 @@ def format_analysis_opts(self, lines: List[str]) -> List[str]:
format_lines = [
".. rubric:: Analysis options",
"",
"These are the keyword arguments of :meth:`run` method.",
"These are the keyword arguments of the :meth:`run` method.",
"",
]
for line in _write_options(lines, self.indent):
Expand Down
7 changes: 5 additions & 2 deletions docs/_ext/custom_styles/option_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from sphinx.ext.napoleon import GoogleDocstring


_parameter_doc_regex = re.compile(r'(.+?)\(\s*(.*[^\s]+)\s*\):(.*[^\s]+)')
_parameter_doc_regex = re.compile(r"(.+?)\(\s*(.*[^\s]+)\s*\):(.*[^\s]+)")


class QiskitExperimentsOptionsDocstring(GoogleDocstring):
Expand Down Expand Up @@ -201,8 +201,11 @@ def _value_repr(value: Any) -> str:
return f"{{{dict_repr}}}"
if value.__class__.__module__ == "builtins":
return f":obj:`{value}`"
if value.__class__.__module__.startswith("qiskit"):
if value.__class__.__module__ and value.__class__.__module__.startswith("qiskit"):
return f"Instance of :class:`.{value.__class__.__name__}`"
# for singleton gates that don't have directly accessible module names
if hasattr(value, "base_class") and value.base_class.__module__.startswith("qiskit"):
return f"Instance of :class:`.{value.base_class.__name__}`"
if callable(value):
return f"Callable :func:`{value.__name__}`"
if isinstance(value, np.ndarray):
Expand Down
10 changes: 3 additions & 7 deletions docs/_templates/autosummary/analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% for item in all_attributes %}
{%- if not item.startswith('_') %}
{{ name }}.{{ item }}
.. autoattribute:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
Expand All @@ -32,16 +30,14 @@

.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% for item in inherited_members %}
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}

Expand Down
61 changes: 20 additions & 41 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,37 @@
:no-inherited-members:
:no-special-members:

{% block attributes_summary %}
{% if attributes %}
{% block attributes_summary %}

{# This counter lets us only render the heading if there's at least
one valid entry. #}
{% set count = namespace(value=0) %}
{% set wanted_attributes = [] %}
{% for item in attributes%}
{%- if not item.startswith('_') %}
{% set _ = wanted_attributes.append(item)%}
{%- endif -%}
{%- endfor %}

{% for item in attributes %}
{% if not item.startswith('_') %}
{% set count.value = count.value + 1 %}
{% if count.value == 1 %}
{% if wanted_attributes %}
.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% endif %}

{{ name }}.{{ item }}
{% endif %}
{% endfor %}
{% for item in wanted_attributes %}
.. autoattribute:: {{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% endblock %}

{% block methods_summary %}
{% if methods %}
{% block methods_summary %}

{% set count = namespace(value=0) %}
{% set wanted_methods = [] %}
{% for item in all_methods %}

{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{% set count.value = count.value + 1 %}
{% if count.value == 1 %}
.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% endif %}
{{ name }}.{{ item }}
{% set _ = wanted_methods.append(item)%}
{%- endif -%}
{%- endfor %}
{% for item in inherited_members %}
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{% set count.value = count.value + 1 %}
{% if count.value == 1 %}
.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% endif %}
{{ name }}.{{ item }}
{%- endif -%}
{% if wanted_methods%}
.. rubric:: Methods
{% for item in wanted_methods %}
.. automethod:: {{ name }}.{{ item }}
{%- endfor %}

{% endif %}
{% endblock %}
{% endblock %}
Loading

0 comments on commit e00ecbc

Please sign in to comment.