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

👷 update framework #367

Merged
merged 21 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
8 changes: 7 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
python-packaging:
name: 🐍 Packaging
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.3
with:
pure-python: true

Expand All @@ -23,13 +23,19 @@ jobs:
url: https://pypi.org/p/mqt.bench
permissions:
id-token: write
attestations: write
contents: read
needs: [python-packaging]
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- name: Generate artifact attestation for sdist and wheel(s)
uses: actions/attest-build-provenance@v1.4.1
with:
subject-path: "dist/*"
- uses: pypa/gh-action-pypi-publish@release/v1

upload_webserver:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ concurrency:
jobs:
change-detection:
name: 🔍 Change
uses: cda-tum/mqt-workflows/.github/workflows/reusable-change-detection.yml@v1.1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-change-detection.yml@v1.3

python-tests:
name: 🐍 Test
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-python-tests)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-ci.yml@v1.1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-ci.yml@v1.3
with:
skip-testing-latest-python: true

code-ql:
name: 📝 CodeQL
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-code-ql)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-code-ql-python.yml@v1.1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-code-ql-python.yml@v1.3

required-checks-pass: # This job does nothing and is only used for branch protection
name: 🚦 Check
Expand Down
75 changes: 47 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ci:
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -28,9 +28,20 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace

# Clean jupyter notebooks
- repo: https://github.com/srstevenson/nb-clean
rev: 3.3.0
hooks:
- id: nb-clean
args:
- --remove-empty-cells
- --preserve-cell-metadata
- raw_mimetype
- --

# Handling unwanted unicode characters
- repo: https://github.com/sirosen/texthooks
rev: "0.6.6"
rev: 0.6.7
hooks:
- id: fix-ligatures
- id: fix-smartquotes
Expand All @@ -43,34 +54,13 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

# Clean jupyter notebooks
- repo: https://github.com/srstevenson/nb-clean
rev: "3.3.0"
hooks:
- id: nb-clean
# Check for spelling
- repo: https://github.com/codespell-project/codespell
rev: "v2.3.0"
hooks:
- id: codespell
args: ["-L", "wille,linz,fro"]
exclude: "mqt/bench/viewer/templates/legal.html"

# Format configuration files with prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, javascript, json]

# Python linting and formatting using ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.6.1
burgholzer marked this conversation as resolved.
Show resolved Hide resolved
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]

# Also run Black on examples in the documentation
- repo: https://github.com/adamchainz/blacken-docs
Expand All @@ -79,11 +69,19 @@ repos:
- id: blacken-docs
additional_dependencies: [black==24.*]

# Format configuration files with prettier
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.3.3
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]

# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
rev: v1.11.1
hooks:
- id: mypy
files: ^(src|tests)
files: ^(src/mqt|test/python)
args: []
additional_dependencies:
- pytket_qiskit
Expand All @@ -97,6 +95,13 @@ repos:
- types-tqdm
- types-flask

# Check for spelling
- repo: https://github.com/crate-ci/typos
rev: v1.23.6
hooks:
- id: typos
exclude: legal.html

# Catch common capitalization mistakes
- repo: local
hooks:
Expand All @@ -108,7 +113,21 @@ repos:

# Check best practices for scientific Python code
- repo: https://github.com/scientific-python/cookie
rev: 2024.04.23
rev: 2024.08.19
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]

# Check JSON schemata
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.1
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs

# Check the pyproject.toml file
- repo: https://github.com/henryiii/validate-pyproject-schema-store
rev: 2024.08.19
hooks:
- id: validate-pyproject
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
nox.options.default_venv_backend = "uv|virtualenv"


PYTHON_ALL_VERSIONS = ["3.10", "3.11", "3.12"]
PYTHON_ALL_VERSIONS = ["3.10", "3.11", "3.12", "3.13"]

BUILD_REQUIREMENTS = [
"setuptools>=66.1",
Expand Down
44 changes: 34 additions & 10 deletions pyproject.toml
burgholzer marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dynamic = ["version"]
dependencies = [
"pytket-qiskit>=0.53.0", # manages the dependencies for qiskit and tket in a combined fashion
"pytket>=1.29.0", # lowest version that supports the used pytket AutoRebase pass instead of auto_rebase
"qiskit!=1.2.0", # there is a bug in 1.2.0 that causes an error some benchmarks, see https://github.com/Qiskit/qiskit/issues/12969
"qiskit_optimization>=0.6",
"qiskit_nature[pyscf]>=0.7",
"qiskit_finance>=0.4.1",
Expand All @@ -45,6 +46,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
Expand Down Expand Up @@ -92,15 +94,23 @@ log_cli_level = "INFO"
xfail_strict = true
filterwarnings = [
"error",
"ignore:.*pkg_resources.*:DeprecationWarning:",
"ignore:.*sre_.*:DeprecationWarning:",
"ignore:.*Rigetti.*:UserWarning:",
"ignore:.*Values in x.*:RuntimeWarning:",
"ignore:.*divide by zero encountered in det.*:RuntimeWarning:",
"ignore:.*invalid value encountered in det.*:RuntimeWarning:",
"ignore::DeprecationWarning:.*(docplex).*",
"ignore::SyntaxWarning:.*(docplex).*",
"ignore:.*The abstract Provider and ProviderV1 classes are deprecated.*:DeprecationWarning:qiskit.*",
'ignore:.*pkg_resources.*:DeprecationWarning:',
'ignore:.*sre_.*:DeprecationWarning:',
'ignore:.*Rigetti.*:UserWarning:',
'ignore:.*Values in x.*:RuntimeWarning:',
'ignore:.*divide by zero encountered in det.*:RuntimeWarning:',
'ignore:.*invalid value encountered in det.*:RuntimeWarning:',
'ignore::DeprecationWarning:.*(docplex).*',
'ignore::SyntaxWarning:.*(docplex).*',
'ignore:.*The abstract Provider and ProviderV1 classes are deprecated.*:DeprecationWarning:qiskit.*',
'ignore:.*qiskit.providers.models is deprecated since Qiskit 1.2*:DeprecationWarning:',
'ignore:.*Treating CircuitInstruction as an iterable is deprecated legacy behavior since Qiskit 1.2*:DeprecationWarning:pytket.*',
'ignore:.*qiskit.providers.models.* is deprecated since qiskit 1.2*:DeprecationWarning:qiskit.*',
'ignore:.*qiskit.providers.models.* is deprecated as of qiskit 1.2*:DeprecationWarning:qiskit.*',
'ignore:.*qiskit.primitives.* is deprecated as of qiskit 1.2*:DeprecationWarning:qiskit.*',
'ignore:.*The class ``qiskit.qobj.pulse_qobj.PulseLibraryItem`` is deprecated as of qiskit 1.2.*:DeprecationWarning:qiskit.*',
'ignore:.*The class ``qiskit.primitives.sampler.Sampler`` is deprecated as of qiskit 1.2*:DeprecationWarning:mqt.*',
'ignore:.*The class ``qiskit.primitives.estimator.Estimator`` is deprecated as of qiskit 1.2*:DeprecationWarning:mqt.*',
burgholzer marked this conversation as resolved.
Show resolved Hide resolved
]

[tool.coverage]
Expand Down Expand Up @@ -137,7 +147,6 @@ ignore_missing_imports = true
[tool.ruff]
line-length = 120
extend-include = ["*.ipynb"]
src = ["src"]
preview = true
unsafe-fixes = true

Expand Down Expand Up @@ -202,3 +211,18 @@ isort.required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.pydocstyle]
convention = "google"


[tool.typos]
default.extend-ignore-re = [
'"id": ".*",',
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$", # ignore line
"(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on" # ignore block
]
[tool.typos.default.extend-words]
wille = "wille"
anc = "anc"
aer = "aer"
fom = "fom"
bench = "bench"
benchs = "benchs"
11 changes: 1 addition & 10 deletions src/mqt/bench/benchmark_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@

from pytket.circuit import Circuit

if TYPE_CHECKING or sys.version_info >= (3, 10, 0): # pragma: no cover
from importlib import resources
else:
import importlib_resources as resources

from dataclasses import dataclass
from importlib import resources


class Benchmark(TypedDict, total=False):
Expand Down Expand Up @@ -359,11 +355,6 @@ def get_benchmark(
Returns:
Quantum Circuit Object representing the benchmark with the selected options, either as Qiskit::QuantumCircuit or Pytket::Circuit object (depending on the chosen compiler---while the algorithm level is always provided using Qiskit)
"""
if "gate_set_name" in kwargs:
msg = "gate_set_name is deprecated and will be removed in a future release. Use provider_name instead."
warn(msg, DeprecationWarning, stacklevel=2)
provider_name = kwargs["gate_set_name"]

if benchmark_name not in utils.get_supported_benchmarks():
msg = f"Selected benchmark is not supported. Valid benchmarks are {utils.get_supported_benchmarks()}."
raise ValueError(msg)
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/bench/benchmarks/random.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Random benchmark definition."""
"""Random benchmark definition.""" # noqa: A005

burgholzer marked this conversation as resolved.
Show resolved Hide resolved
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions src/mqt/bench/devices/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_two_qubit_gate_fidelity(self, gate_type: str, qubit1: int, qubit2: int)
raise ValueError(msg)

try:
return self.two_qubit_gate_fidelity[(qubit1, qubit2)][gate_type]
return self.two_qubit_gate_fidelity[qubit1, qubit2][gate_type]
except KeyError:
msg = f"Two-qubit fidelity for gate {gate_type} and qubits {qubit1} and {qubit2} not available."
raise ValueError(msg) from None
Expand All @@ -95,7 +95,7 @@ def get_two_qubit_gate_duration(self, gate_type: str, qubit1: int, qubit2: int)
raise ValueError(msg)

try:
return self.two_qubit_gate_duration[(qubit1, qubit2)][gate_type]
return self.two_qubit_gate_duration[qubit1, qubit2][gate_type]
except KeyError:
msg = f"Two-qubit duration for gate {gate_type} and qubits {qubit1} and {qubit2} not available."
raise ValueError(msg) from None
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/bench/devices/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_two_qubit_gates(self) -> set[str]:
return {
gate
for qubit1, qubit2 in self.coupling_map
for gate in self.calibration.two_qubit_gate_fidelity[(qubit1, qubit2)]
for gate in self.calibration.two_qubit_gate_fidelity[qubit1, qubit2]
}

def sanitize_device(self) -> None:
Expand Down
Loading
Loading