diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 446bf8d..548f120 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -26,15 +26,36 @@ 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 @@ -42,30 +63,37 @@ repos: - 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 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..6b1d0bf --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +LICENSE diff --git a/.taplo.toml b/.taplo.toml index bcd3669..0db1df7 100644 --- a/.taplo.toml +++ b/.taplo.toml @@ -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 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index b4d6265..fbeb4b8 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -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" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 8b24c13..4dc84f1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" } diff --git a/README.md b/README.md index 77f8154..7cd98ad 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/pyproject.toml b/pyproject.toml index 5be28cc..8f6782d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,9 @@ requires = [ ] [project] +authors = [ + {name = "Common Partial Wave Analysis", email = "compwa-admin@ep1.rub.de"}, +] classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", @@ -42,12 +45,11 @@ keywords = [ "physics", "tensorflow", ] -license = { file = "LICENSE" } +license = {file = "LICENSE"} maintainers = [ - { name = "Common Partial Wave Analysis", email = "compwa-admin@ep1.rub.de" }, + {name = "Common Partial Wave Analysis", email = "compwa-admin@ep1.rub.de"}, ] name = "jax-mini-benchmark" -readme = "README.md" requires-python = ">=3.7" [project.optional-dependencies] @@ -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" @@ -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 = ''' /( @@ -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 diff --git a/src/jax_benchmark/__init__.py b/src/jax_benchmark/__init__.py index ee68c51..95dbb41 100644 --- a/src/jax_benchmark/__init__.py +++ b/src/jax_benchmark/__init__.py @@ -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: diff --git a/visualize-benchmark.ipynb b/visualize-benchmark.ipynb index 3c3eba1..7a2c888 100644 --- a/visualize-benchmark.ipynb +++ b/visualize-benchmark.ipynb @@ -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", @@ -39,7 +40,7 @@ " # if k % 2 == 0\n", " # if k < 6\n", " }\n", - ")\n" + ")" ] }, { @@ -80,6 +81,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "tw", "language": "python", @@ -97,7 +101,6 @@ "pygments_lexer": "ipython3", "version": "3.8.16" }, - "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "941585edea6bc165435aa3186ccdcc04147aa4112b01c30ec33a5464a4b433ae"