Skip to content

Commit

Permalink
MAINT: autoupdate pre-commit hooks (#4)
Browse files Browse the repository at this point in the history
* DOC: make Colab TOC visible by default
* DX: lint PRs with shared commitlint config
* DX: merge `setup.cfg` into `pyproject.toml`
* DX: switch to `black-jupyter` hook
* DX: remove `.prettierrc`
* DX: remove GitHub Issue templates
* DX: synchronize ComPWA dev environment

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
redeboer and pre-commit-ci[bot] authored Oct 9, 2023
1 parent a9bc446 commit e55fda8
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 33 deletions.
44 changes: 36 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand All @@ -26,46 +26,74 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.9.1
hooks:
- id: black
- id: black-jupyter
args: [--line-length=85]
types_or: [jupyter]

- repo: https://github.com/ComPWA/repo-maintenance
rev: 0.1.0
hooks:
- id: colab-toc-visible
- id: check-dev-files
args:
- --no-github-actions
- --no-gitpod
- --no-prettierrc
- --no-pypi
- --no-ruff
- --repo-name=jax-mini-benchmark

- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.2
hooks:
- id: editorconfig-checker
name: editorconfig-checker
name: editorconfig
alias: ec
exclude: >-
(?x)^(
.*\.py
)$
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0
rev: v3.0.3
hooks:
- id: prettier

- repo: https://github.com/ComPWA/mirrors-pyright
rev: v1.1.316
rev: v1.1.330
hooks:
- id: pyright

- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
rev: v3.15.0
hooks:
- id: pyupgrade
args:
- --py37-plus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.277
rev: v0.0.292
hooks:
- id: ruff
args:
- --fix

- repo: https://github.com/ComPWA/mirrors-taplo
rev: v0.8.0
rev: v0.8.1
hooks:
- id: taplo

- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort
args:
- --in-place
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LICENSE
3 changes: 3 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[formatting]
align_comments = false
align_entries = false
allowed_blank_lines = 1
array_auto_collapse = false
array_auto_expand = true
array_trailing_comma = true
column_width = 88
compact_inline_tables = true
indent_string = " "
reorder_arrays = true
reorder_keys = true
6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"stkb.rewrap",
"tamasfe.even-better-toml",
"tyriar.sort-lines",
"yzhang.markdown-all-in-one"
],
"unwantedRecommendations": [
"bungcip.better-toml",
"davidanson.vscode-markdownlint",
"ms-python.flake8",
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.pylint"
"ms-python.pylint",
"travisillig.vscode-json-stable-stringify"
]
}
11 changes: 9 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"[git-commit]": {
"editor.rulers": [72],
"rewrap.wrappingColumn": 72
},
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.rulers": [88]
},
"black-formatter.importStrategy": "fromEnvironment",
"editor.formatOnSave": true,
"python.analysis.typeCheckingMode": "strict",
"python.formatting.provider": "black",
"rewrap.wrappingColumn": 88,
"ruff.enable": true,
"ruff.importStrategy": "fromEnvironment"
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Mini benchmark for JAX

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

This package provides a set of benchmark scripts that can be used to profile JAX performance on a varying number of CPU cores. JAX does not provide control over the number of cores it uses, so a common trick is to work do this with [`taskset`](https://man7.org/linux/man-pages/man1/taskset.1.html).

The benchmarks can be run by installing the package with [`pip`](https://pypi.org/project/pip) and running it as follows:
Expand Down
43 changes: 31 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ requires = [
]

[project]
authors = [
{name = "Common Partial Wave Analysis", email = "[email protected]"},
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
Expand Down Expand Up @@ -42,12 +45,11 @@ keywords = [
"physics",
"tensorflow",
]
license = { file = "LICENSE" }
license = {file = "LICENSE"}
maintainers = [
{ name = "Common Partial Wave Analysis", email = "[email protected]" },
{name = "Common Partial Wave Analysis", email = "[email protected]"},
]
name = "jax-mini-benchmark"
readme = "README.md"
requires-python = ">=3.7"

[project.optional-dependencies]
Expand All @@ -58,6 +60,10 @@ sty = [
"ruff",
]

[project.readme]
content-type = "text/markdown"
file = "README.md"

[project.scripts]
benchmark-jax = "jax_benchmark:main"
benchmark-jax-dot-product = "jax_benchmark.dot_product:main"
Expand All @@ -67,6 +73,15 @@ Documentation = "https://github.com/ComPWA/jax-mini-benchmark"
Source = "https://github.com/ComPWA/jax-mini-benchmark"
Tracker = "https://github.com/ComPWA/jax-mini-benchmark/issues"

[tool.setuptools.package-data]
jax_benchmark = ["py.typed"]

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools_scm]
write_to = "src/jax_benchmark/_version.py"

[tool.black]
exclude = '''
/(
Expand Down Expand Up @@ -147,12 +162,16 @@ src = ["src"]
target-version = "py37"
task-tags = ["cspell"]

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
jax_benchmark = ["py.typed"]


[tool.setuptools_scm]
write_to = "src/jax_benchmark/_version.py"
[tool.tomlsort]
all = false
ignore_case = true
in_place = true
sort_first = [
"build-system",
"project",
"tool.setuptools",
"tool.setuptools_scm",
]
sort_table_keys = true
spaces_indent_inline_array = 4
trailing_comma_inline_array = true
14 changes: 6 additions & 8 deletions src/jax_benchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,12 @@ def run_single_benchmark(
shape_str = "x".join(map(str, shape))
filename.parent.mkdir(exist_ok=True, parents=True)
subprocess.call(
(
f"taskset -c 0-{n_cpus-1}"
" benchmark-jax-dot-product"
f" --output={filename}"
f" --number={number}"
f" --repeat={repeat}"
f" --shape={shape_str}"
),
f"taskset -c 0-{n_cpus-1}"
" benchmark-jax-dot-product"
f" --output={filename}"
f" --number={number}"
f" --repeat={repeat}"
f" --shape={shape_str}",
shell=True,
)
with open(filename) as f:
Expand Down
7 changes: 5 additions & 2 deletions visualize-benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
" with open(filename, \"rb\") as f:\n",
" return pickle.load(f)\n",
"\n",
"\n",
"benchmarks: dict[int | str, TimeitResult] = {}\n",
"benchmarks[\"all\"] = load_benchmark(f\"timing_all.pickle\")\n",
"for i in range(12):\n",
Expand All @@ -39,7 +40,7 @@
" # if k % 2 == 0\n",
" # if k < 6\n",
" }\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -80,6 +81,9 @@
}
],
"metadata": {
"colab": {
"toc_visible": true
},
"kernelspec": {
"display_name": "tw",
"language": "python",
Expand All @@ -97,7 +101,6 @@
"pygments_lexer": "ipython3",
"version": "3.8.16"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "941585edea6bc165435aa3186ccdcc04147aa4112b01c30ec33a5464a4b433ae"
Expand Down

0 comments on commit e55fda8

Please sign in to comment.