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

MAINT: autoupdate pre-commit hooks #22

Merged
merged 7 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 2 additions & 21 deletions .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected] # cspell:ignore kode
lint-pr:
uses: ComPWA/actions/.github/workflows/pr-linting.yml@v1
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
30 changes: 12 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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]
8 changes: 4 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
16 changes: 12 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -20,25 +21,32 @@
"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": {
".cspell/*.txt": "plaintext"
},
"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"
}
12 changes: 3 additions & 9 deletions docs/visualize-jax-benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
48 changes: 17 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ doc = [
"sphinx-copybutton",
"sphinx-togglebutton",
]
format = [
"black",
]
jupyter = [
"isort",
"jupyterlab >=3.0",
Expand All @@ -76,6 +73,7 @@ sty = [
"benchmarks[lint]",
"benchmarks[types]",
"pre-commit >=1.4.0",
"ruff",
]
test = [
"nbmake",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -240,7 +226,7 @@ task-tags = ["cspell"]
"scripts/*" = ["INP001"]
"setup.py" = ["D100"]

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

[tool.tomlsort]
Expand Down
8 changes: 4 additions & 4 deletions scripts/execute_jax_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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,
Expand Down
Loading