diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2eaff7b..2708cfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,8 @@ name: CI concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: |- + ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} env: PYTHONHASHSEED: "0" diff --git a/.github/workflows/pr-linting.yml b/.github/workflows/pr-linting.yml index cd3bb74..0fab841 100644 --- a/.github/workflows/pr-linting.yml +++ b/.github/workflows/pr-linting.yml @@ -10,24 +10,5 @@ on: - unlabeled jobs: - check-labels: - name: Check labels - runs-on: ubuntu-22.04 - steps: - - uses: docker://agilepathway/pull-request-label-checker:latest # cspell:ignore agilepathway - with: - any_of: >- - 🐛 Bug,✨ Feature,⚙️ Enhancement,⚠️ Interface,❗ Behavior,📝 Docs,🔨 Maintenance,🖱️ DX - none_of: Epic,💫 Good first issue - repo_token: ${{ secrets.GITHUB_TOKEN }} - - check-title: - name: Check title - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - run: npm install @compwa/commitlint-config - - name: Create commitlint config - run: | - echo "module.exports = {extends: ['@compwa/commitlint-config']}" > commitlint.config.js - - uses: JulienKode/pull-request-name-linter-action@v0.5.0 # cspell:ignore kode + lint-pr: + uses: ComPWA/actions/.github/workflows/pr-linting.yml@v1 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index d64f197..5234093 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -11,6 +11,6 @@ jobs: update_release_draft: runs-on: ubuntu-22.04 steps: - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2307886..5da1767 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/kynan/nbstripout - rev: 0.6.1 + rev: 0.7.1 hooks: - id: nbstripout args: @@ -38,7 +38,7 @@ repos: metadata.vscode - repo: https://github.com/ComPWA/policy - rev: 0.2.3 + rev: 0.3.4 hooks: - id: check-dev-files args: @@ -49,6 +49,15 @@ repos: - --repo-title=benchmarks - id: colab-toc-visible + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.5 + hooks: + - id: ruff + args: [--fix] + types_or: [python, pyi, jupyter] + - id: ruff-format + types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -64,14 +73,6 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 - hooks: - - id: black - - id: black-jupyter - args: [--line-length=85] - types_or: [jupyter] - - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 hooks: @@ -101,13 +102,6 @@ repos: )$ - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.345 + rev: v1.1.357 hooks: - id: pyright - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.13 - hooks: - - id: ruff - args: [--fix] - types_or: [python, pyi, jupyter] diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 72f5509..dba1484 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -7,28 +7,28 @@ "executablebookproject.myst-highlight", "github.vscode-github-actions", "github.vscode-pull-request-github", - "ms-python.black-formatter", "ms-python.python", "ms-python.vscode-pylance", "ms-vscode.live-server", "ms-vsliveshare.vsliveshare", "oijaz.unicode-latex", "redhat.vscode-yaml", - "Soulcode.vscode-unwanted-extensions", + "soulcode.vscode-unwanted-extensions", "stkb.rewrap", "tamasfe.even-better-toml", - "tyriar.sort-lines", "yzhang.markdown-all-in-one" ], "unwantedRecommendations": [ "bungcip.better-toml", "davidanson.vscode-markdownlint", "garaioag.garaio-vscode-unwanted-recommendations", + "ms-python.black-formatter", "ms-python.flake8", "ms-python.isort", "ms-python.mypy-type-checker", "ms-python.pylint", "streetsidesoftware.code-spell-checker", - "travisillig.vscode-json-stable-stringify" + "travisillig.vscode-json-stable-stringify", + "tyriar.sort-lines" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 70e723a..00bdf75 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,8 @@ "rewrap.wrappingColumn": 72 }, "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.wordWrap": "on" }, "[jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode" @@ -20,13 +21,12 @@ "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": "charliermarsh.ruff", "editor.rulers": [88] }, "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "black-formatter.importStrategy": "fromEnvironment", "diffEditor.experimental.showMoves": true, "editor.formatOnSave": true, "files.associations": { @@ -34,11 +34,19 @@ }, "files.eol": "\n", "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], + "gitlens.telemetry.enabled": false, "livePreview.defaultPreviewPath": "docs/_build/html", "multiDiffEditor.experimental.enabled": true, + "notebook.codeActionsOnSave": { + "notebook.source.organizeImports": "explicit" + }, + "notebook.formatOnSave.enabled": true, "notebook.gotoSymbols.showAllSymbols": true, "python.analysis.autoImportCompletions": false, + "redhat.telemetry.enabled": false, "rewrap.wrappingColumn": 88, "ruff.enable": true, - "ruff.organizeImports": true + "ruff.importStrategy": "fromEnvironment", + "ruff.organizeImports": true, + "telemetry.telemetryLevel": "off" } diff --git a/docs/visualize-jax-benchmark.ipynb b/docs/visualize-jax-benchmark.ipynb index cfd2d03..01b0c5f 100644 --- a/docs/visualize-jax-benchmark.ipynb +++ b/docs/visualize-jax-benchmark.ipynb @@ -99,13 +99,9 @@ "df = pd.DataFrame(\n", " {\n", " (\"sample size\", \"\"): X[::2],\n", - " (\"1 CPU\", \"parametrized\"): Y_1CPU[f\"{parametrized}, run 2\"].mean(axis=1)[\n", - " ::2\n", - " ],\n", + " (\"1 CPU\", \"parametrized\"): Y_1CPU[f\"{parametrized}, run 2\"].mean(axis=1)[::2],\n", " (\"1 CPU\", \"substituted\"): Y_1CPU[f\"{substituted}, run 2\"].mean(axis=1)[::2],\n", - " (\"8 CPUs\", \"parametrized\"): Y_8CPU[f\"{parametrized}, run 2\"].mean(axis=1)[\n", - " ::2\n", - " ],\n", + " (\"8 CPUs\", \"parametrized\"): Y_8CPU[f\"{parametrized}, run 2\"].mean(axis=1)[::2],\n", " (\"8 CPUs\", \"substituted\"): Y_8CPU[f\"{substituted}, run 2\"].mean(axis=1)[::2],\n", " },\n", ")\n", @@ -223,9 +219,7 @@ " return y_1cpu / y_8cpu\n", "\n", "\n", - "def create_multithreading_ratio_plot(\n", - " substract_base_time: bool, savefig: bool = False\n", - "):\n", + "def create_multithreading_ratio_plot(substract_base_time: bool, savefig: bool = False):\n", " plt.rc(\"font\", size=12)\n", " fig, axes = plt.subplots(figsize=(8, 4), ncols=2, tight_layout=True)\n", " ax1, ax2 = axes\n", diff --git a/pyproject.toml b/pyproject.toml index d762174..3e1e7e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,9 +53,6 @@ doc = [ "sphinx-copybutton", "sphinx-togglebutton", ] -format = [ - "black", -] jupyter = [ "isort", "jupyterlab >=3.0", @@ -76,6 +73,7 @@ sty = [ "benchmarks[lint]", "benchmarks[types]", "pre-commit >=1.4.0", + "ruff", ] test = [ "nbmake", @@ -91,30 +89,6 @@ file = "README.md" [tool.setuptools] include-package-data = false -[tool.black] -exclude = ''' -/( - .*\.egg-info - | .*build - | \.eggs - | \.git - | \.pytest_cache - | \.tox - | \.venv - | \.vscode - | dist -)/ -''' -include = '\.pyi?$' -preview = true -target-version = [ - "py310", - "py311", - "py37", - "py38", - "py39", -] - [tool.pyright] reportGeneralTypeIssues = false reportImportCycles = false @@ -162,6 +136,15 @@ testpaths = [ [tool.ruff] extend-include = ["*.ipynb"] +preview = true +show-fixes = true +target-version = "py37" + +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" + +[tool.ruff.lint] extend-select = [ "A", "B", @@ -205,13 +188,16 @@ ignore = [ "D407", "D416", "E501", + "ISC001", + "PLW1514", "SIM108", ] -show-fixes = true -target-version = "py37" task-tags = ["cspell"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.isort] +split-on-trailing-comma = false + +[tool.ruff.lint.per-file-ignores] "*.ipynb" = [ "B018", "C408", @@ -240,7 +226,7 @@ task-tags = ["cspell"] "scripts/*" = ["INP001"] "setup.py" = ["D100"] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" [tool.tomlsort] diff --git a/scripts/execute_jax_benchmark.py b/scripts/execute_jax_benchmark.py index a371b0b..3c61ea7 100644 --- a/scripts/execute_jax_benchmark.py +++ b/scripts/execute_jax_benchmark.py @@ -60,7 +60,7 @@ def main() -> int: - t: dict[str, dict[str, list[float]]] = defaultdict(lambda: defaultdict(list)) + t: dict[int, dict[str, list[float]]] = defaultdict(lambda: defaultdict(list)) output_file = f"{THIS_DIRECTORY}/computation_times.yaml" if os.path.exists(output_file): imported_times = load_benchmark(output_file) @@ -111,7 +111,7 @@ def create_amplitude_model() -> AmplitudeModel: ) reference_subsystem = 1 model = amplitude_builder.formulate(reference_subsystem) - model.parameter_defaults.update(imported_parameter_values) + model.parameter_defaults.update(imported_parameter_values) # pyright:ignore[reportArgumentType,reportCallIssue] return model @@ -173,12 +173,12 @@ def benchmark(func: Function, sample: DataSample) -> float: return stop - start -def load_benchmark(filename: str) -> dict[str, dict[str, list[float]]]: +def load_benchmark(filename: str) -> dict[int, dict[str, list[float]]]: with open(filename) as f: return yaml.safe_load(f) -def write_benchmark(times: dict[str, dict[str, list[float]]], filename: str) -> None: +def write_benchmark(times: dict[int, dict[str, list[float]]], filename: str) -> None: with open(filename, "w") as f: yaml.dump( times,