Skip to content

Commit

Permalink
⬆️ update workflows and project configuration (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
burgholzer authored Oct 9, 2024
2 parents 0c1364e + f8e22a3 commit 7d3a2ae
Show file tree
Hide file tree
Showing 11 changed files with 2,453 additions and 52 deletions.
47 changes: 36 additions & 11 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,57 @@
name: CD
on:
push:
branches: [main]
release:
types: [published]
workflow_dispatch:
pull_request:
paths:
- .github/workflows/cd.yml

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
attestations: write
contents: read
id-token: write

jobs:
# Builds the sdist and wheels on all supported platforms and uploads the resulting
# wheels as GitHub artifacts `dev-cibw-*`, `test-cibw-*`, or `cibw-*`, depending on
# whether the workflow is triggered from a PR, a push to main, or a release, respectively.
python-packaging:
name: 🐍 Packaging
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
# Do not include local version information on pushes to main to facilitate TestPyPI uploads.
no-local-version: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
# Do not build emulated wheels on pushes to main to reduce runner load for CD.
build-emulated-wheels: ${{ github.ref != 'refs/heads/main' || github.event_name != 'push' }}

# Downloads the previously generated artifacts and deploys to TestPyPI on pushes to main
deploy-test-pypi:
name: 🚀 Deploy to Test PyPI
runs-on: ubuntu-latest
environment:
name: test-pypi
url: https://test.pypi.org/p/mqt.qudits
needs: [python-packaging]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/download-artifact@v4
with:
pattern: test-cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
attestations: true

# Downloads the previously generated artifacts and deploys to PyPI on published releases.
deploy:
if: github.event_name == 'release' && github.event.action == 'published'
name: 🚀 Deploy to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/mqt.qudits
permissions:
id-token: write
attestations: write
contents: read
needs: [python-packaging]
steps:
- uses: actions/download-artifact@v4
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ concurrency:
jobs:
change-detection:
name: 🔍 Change
uses: cda-tum/mqt-workflows/.github/workflows/reusable-change-detection.yml@v1.3
uses: cda-tum/mqt-workflows/.github/workflows/reusable-change-detection.yml@v1.4

cpp-tests:
name: 🇨‌ Test
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-tests)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-ci.yml@v1.3
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-ci.yml@v1.4
with:
cmake-args: ""
cmake-args-ubuntu: -G Ninja
Expand All @@ -31,21 +31,25 @@ jobs:
name: 🇨‌ Lint
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-linter)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-linter.yml@v1.3
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-linter.yml@v1.4

python-tests:
name: 🐍 Test
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-python-tests)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
skip-testing-latest-python: true
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]

code-ql:
name: 📝 CodeQL
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-code-ql)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]

cd:
name: 🚀 CD
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cd)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]

required-checks-pass: # This job does nothing and is only used for branch protection
name: 🚦 Check
Expand All @@ -56,6 +60,7 @@ jobs:
- cpp-linter
- python-tests
- code-ql
- cd
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand All @@ -78,4 +83,8 @@ jobs:
fromJSON(needs.change-detection.outputs.run-code-ql)
&& '' || 'code-ql,'
}}
${{
fromJSON(needs.change-detection.outputs.run-cd)
&& '' || 'cd,'
}}
jobs: ${{ toJSON(needs) }}
4 changes: 2 additions & 2 deletions .github/workflows/update-mqt-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ concurrency:
jobs:
update-mqt-core:
name: ⬆️ Update MQT Core
uses: cda-tum/mqt-workflows/.github/workflows/reusable-mqt-core-update.yml@v1.3
uses: cda-tum/mqt-workflows/.github/workflows/reusable-mqt-core-update.yml@v1.4
with:
update-to-head: ${{ github.event.inputs.update-to-head || false }}
update-to-head: ${{ github.event.inputs.update-to-head == 'true' }}
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,10 @@ repos:
types_or: [yaml, markdown, html, css, scss, javascript, json]

# Check for spelling
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
- repo: https://github.com/crate-ci/typos
rev: v1.26.0
hooks:
- id: codespell
args: ["-L", "wille,linz", "--skip", "*.ipynb"]
- id: typos

# Catch common capitalization mistakes
- repo: local
Expand Down
1 change: 1 addition & 0 deletions .python_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
9 changes: 4 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

nox.options.sessions = ["lint", "tests", "minimums"]

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

# The following lists all the build requirements for building the package.
# Note that this includes transitive build dependencies of package dependencies,
Expand All @@ -27,9 +27,8 @@
# not available via wheels on PyPI (i.e., only as source distributions).
BUILD_REQUIREMENTS = [
"scikit-build-core>=0.10.1",
"setuptools_scm>=7",
"setuptools_scm>=8.1",
"pybind11>=2.13.5",
"wheel>=0.40", # transitive dependency of pytest on Windows
]

if os.environ.get("CI", None):
Expand Down Expand Up @@ -69,7 +68,7 @@ def _run_tests(

session.install(*BUILD_REQUIREMENTS, *install_args, env=env)
install_arg = f"-ve.[{','.join(_extras)}]"
session.install("--no-build-isolation", "--reinstall-package", "mqt.qudits", install_arg, *install_args, env=env)
session.install("--no-build-isolation", install_arg, *install_args, env=env)
session.run("pytest", *run_args, *posargs, env=env)


Expand Down Expand Up @@ -100,7 +99,7 @@ def docs(session: nox.Session) -> None:
serve = args.builder == "html" and session.interactive
extra_installs = ["sphinx-autobuild"] if serve else []
session.install(*BUILD_REQUIREMENTS, *extra_installs)
session.install("--no-build-isolation", "-ve.[docs]", "--reinstall-package", "mqt.qudits")
session.install("--no-build-isolation", "-ve.[docs]")
session.chdir("docs")

if args.builder == "linkcheck":
Expand Down
47 changes: 31 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
requires = [
"scikit-build-core>=0.10.1",
"setuptools-scm>=7",
"setuptools-scm>=8.1",
"pybind11>=2.13.5",
]
build-backend = "scikit_build_core.build"
Expand Down Expand Up @@ -55,23 +55,19 @@ dependencies = [
dynamic = ["version"]

[project.optional-dependencies]
test = ["pytest>=7.0"]
test = ["pytest>=7.2"]
coverage = ["mqt.qudits[test]", "pytest-cov>=4"]
docs = [
"furo>=2023.08.17",
"sphinx",
"furo>=2023.9.10",
"myst_nb>=1.1.0",
"setuptools-scm>=7",
"sphinx-copybutton",
"sphinx_design",
"setuptools-scm>=8.1",
"sphinx-copybutton>=0.5",
"sphinx_design>=0.6",
"sphinx-inline-tabs",
"sphinxext-opengraph",
"sphinxext-opengraph>=0.9",
"sphinxcontrib-bibtex>=2.4.2",
"sphinxcontrib-svg2pdfconverter",
"pybtex>=0.24",
"ipython",
"ipykernel",
"sphinx-autoapi",
"sphinxcontrib-svg2pdfconverter>=1.2",
"sphinx-autoapi>=3",
]
dev = ["mqt.qudits[coverage,docs]"]

Expand All @@ -92,7 +88,7 @@ wheel.install-dir = "mqt/qudits"
ninja.version = ">=1.10"

# Setuptools-style build caching in a local directory
build-dir = "build/{build_type}"
build-dir = "build/{wheel_tag}/{build_type}"

# Explicitly set the package directory
wheel.packages = ["src/mqt"]
Expand Down Expand Up @@ -142,7 +138,7 @@ write_to = "src/mqt/qudits/_version.py"


[tool.pytest.ini_options]
minversion = "7.0"
minversion = "7.2"
addopts = ["-ra", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = [
Expand Down Expand Up @@ -264,6 +260,17 @@ isort.required-imports = ["from __future__ import annotations"]
convention = "google"


[tool.typos]
default.extend-ignore-re = [
"(?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"
mone = "mone"


[tool.repo-review]
ignore = ["GH200"]

Expand All @@ -290,4 +297,12 @@ environment = { MACOSX_DEPLOYMENT_TARGET = "10.15" }
[tool.cibuildwheel.windows]
before-build = "pip install delvewheel>=1.7.3"
repair-wheel-command = "delvewheel repair -v -w {dest_dir} {wheel} --namespace-pkg mqt"
environment = { CMAKE_ARGS = "-T ClangCL", SKBUILD_CMAKE_ARGS="--fresh" }
environment = { CMAKE_ARGS = "-T ClangCL" }

[[tool.cibuildwheel.overrides]]
select = "*-macosx_arm64"
environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }


[tool.uv]
reinstall-package = ["mqt.qudits"]
4 changes: 2 additions & 2 deletions src/mqt/qudits/quantum_circuit/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ def to_qasm(self) -> str:
for op in self.instructions:
text += op.__qasm__()

cregs_indeces = iter(list(range(len(self.dimensions))))
cregs_indices = iter(list(range(len(self.dimensions))))
for qreg in self.quantum_registers:
for i in range(qreg.size):
text += f"measure {qreg.label}[{i}] -> meas[{next(cregs_indeces)}];\n"
text += f"measure {qreg.label}[{i}] -> meas[{next(cregs_indices)}];\n"

return text

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def generate_matrix(self) -> NDArray[np.complex128]:
# preferably only CONTROLLED-One qudit gates to be made as multi-controlled, it is still a low level
# control library

matrix = MatrixFactory.apply_identites_and_controls(
matrix = MatrixFactory.apply_identities_and_controls(
matrix, self.gate.target_qudits, dimensions_slice, ref_slice, controls, ctrl_levs
)
elif self.ids > 0:
matrix = MatrixFactory.apply_identites_and_controls(
matrix = MatrixFactory.apply_identities_and_controls(
matrix, self.gate.target_qudits, dimensions_slice, ref_slice
)

Expand All @@ -50,7 +50,7 @@ def generate_matrix(self) -> NDArray[np.complex128]:
return matrix

@classmethod
def apply_identites_and_controls(
def apply_identities_and_controls(
cls,
matrix: NDArray[np.complex128],
qudits_applied: int | list[int],
Expand Down
4 changes: 2 additions & 2 deletions src/mqt/qudits/simulation/backends/stochastic_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def stochastic_simulation(backend: Backend, circuit: QuantumCircuit) -> NDArray
args_tn = [(backend, factory) for _ in range(shots)]
results = pool.map(stochastic_execution_tn, args_tn)
elif isinstance(backend, MISim):
args_mis = [(backend, circuit, noise_model) for _ in range(shots)]
results = pool.map(stochastic_execution_mi, args_mis)
args_misim = [(backend, circuit, noise_model) for _ in range(shots)]
results = pool.map(stochastic_execution_mi, args_misim)
else:
msg = "Unsupported backend type"
raise TypeError(msg)
Expand Down
Loading

0 comments on commit 7d3a2ae

Please sign in to comment.