Skip to content

Commit

Permalink
FIX: define dev dependencies as dependency groups (#108)
Browse files Browse the repository at this point in the history
* BREAK: convert package dependencies to notebook dependencies
* DX: define `tox -e nb` job
* DX: move `sphinx-autobuild` to `dev dependencies
* FIX: remove `pre-commit-uv` and `tox` from environment
* FIX: remove duplicate `taplo` pre-commit hook
* FIX: set `passenv` in jobs that have a different `base`
* MAINT: apply Ruff fixes
* MAINT: move `pre-commit` `--all-files` flag
* MAINT: update lock files
  • Loading branch information
redeboer authored Oct 28, 2024
1 parent 4ff4944 commit 40853e0
Show file tree
Hide file tree
Showing 8 changed files with 316 additions and 433 deletions.
5 changes: 4 additions & 1 deletion .binder/postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
uv export \
--extra jupyter \
--group jupyter \
--group notebooks \
--no-dev \
> requirements.txt
uv pip install \
--requirement requirements.txt \
--system
rm requirements.txt
uv cache clean
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:

jobs:
doc:
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2.1
permissions:
pages: write
id-token: write
Expand Down
11 changes: 3 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.5.0
rev: 0.5.5
hooks:
- id: check-dev-files
args:
Expand Down Expand Up @@ -51,7 +51,7 @@ repos:
metadata.vscode
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.7.1
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -81,11 +81,6 @@ repos:
hooks:
- id: taplo-format

- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format

- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
Expand All @@ -105,6 +100,6 @@ repos:
)$
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.24
rev: 0.4.27
hooks:
- id: uv-lock
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ build:
pixi global install uv
- |-
export UV_LINK_MODE=copy
uv run --extra doc --locked --with tox \
uv run \
--group doc \
--locked \
--no-dev \
--with tox \
tox -e doc
mkdir -p $READTHEDOCS_OUTPUT
mv docs/_build/html $READTHEDOCS_OUTPUT
2 changes: 1 addition & 1 deletion docs/eta-pi-p/automated.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@
" color_id = 0\n",
" for recoil_id, ax in enumerate(axes):\n",
" decay_products = sorted({0, 1, 2} - {recoil_id})\n",
" key = f\"m_{\"\".join(str(i) for i in decay_products)}\"\n",
" key = f\"m_{''.join(str(i) for i in decay_products)}\"\n",
" bin_values, bin_edges = jax.numpy.histogram(\n",
" phsp[key].real,\n",
" bins=120,\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/lambda-k-pi/ampform.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@
" color_id = 0\n",
" for recoil_id, ax in enumerate(axes):\n",
" decay_products = sorted({0, 1, 2} - {recoil_id})\n",
" key = f\"m_{\"\".join(str(i) for i in decay_products)}\"\n",
" key = f\"m_{''.join(str(i) for i in decay_products)}\"\n",
" bin_values, bin_edges = jax.numpy.histogram(\n",
" phsp[key].real,\n",
" bins=120,\n",
Expand Down
70 changes: 34 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,50 @@ requires = ["setuptools"]

[project]
authors = [{name = "Vitor Shen"}]
dependencies = [
"ampform",
"ampform-dpd",
"graphviz",
"ipympl",
"ipywidgets",
"jax",
"jaxlib",
"matplotlib",
"myst-nb",
"numpy",
"pandas",
"phasespace",
"pre-commit-uv",
"python-lsp-ruff",
"python-lsp-server",
"qrules",
"ruff",
"sphinx-autobuild",
"sphinx-book-theme",
"sphinx-comments",
"sphinx-copybutton",
"sympy",
"tensorflow",
"tensorwaves",
]
license = {file = "LICENSE"}
name = "gluex-nstar"
readme = "README.md"
requires-python = ">=3.12"
version = "0.1.0"

[project.optional-dependencies]
[dependency-groups]
dev = [
"gluex-nstar[doc]",
"gluex-nstar[jupyter]",
"gluex-nstar[sty]",
"pre-commit-uv",
"tox",
"ruff",
"sphinx-autobuild",
{include-group = "doc"},
{include-group = "jupyter"},
{include-group = "test"},
]
doc = [
"sphinx-autobuild",
"myst-nb",
"sphinx-book-theme",
"sphinx-comments",
"sphinx-copybutton",
{include-group = "notebooks"},
]
jupyter = [
"jupyterlab",
"jupyterlab-code-formatter >=3.0.0",
"jupyterlab-code-formatter",
"jupyterlab-git",
"jupyterlab-lsp",
"jupyterlab-myst",
"python-lsp-ruff",
"python-lsp-server[rope]",
{include-group = "notebooks"},
]
notebooks = [
"ampform",
"ampform-dpd",
"ipympl",
"ipywidgets",
"matplotlib",
"qrules[viz]",
"tensorwaves[jax,pwa]",
]
test = [
"nbmake",
{include-group = "notebooks"},
]
sty = ["ruff"]

[tool.ruff]
extend-include = ["*.ipynb"]
Expand Down Expand Up @@ -192,13 +180,15 @@ setenv =
[testenv:docnb]
base = doc
description = {[testenv:doc]description} with cached notebook execution
passenv = *
setenv =
{[testenv:doc]setenv}
EXECUTE_NB = yes
[testenv:docnb-force]
base = doc
description = {[testenv:doc]description} with notebook execution (no cache)
passenv = *
setenv =
{[testenv:doc]setenv}
FORCE_EXECUTE_NB = yes
Expand Down Expand Up @@ -238,6 +228,7 @@ setenv =
[testenv:docnblive]
base = doclive
description = {[testenv:doclive]description} with cached notebook execution
passenv = *
setenv =
{[testenv:doclive]setenv}
EXECUTE_NB = yes
Expand All @@ -254,10 +245,17 @@ description = Check external links in the documentation (requires internet conne
setenv =
{[testenv:doclive]setenv}
[testenv:nb]
allowlist_externals =
pytest
commands =
pytest --nbmake {posargs:docs}
description = Run all notebooks with pytest
[testenv:sty]
allowlist_externals =
pre-commit
commands =
pre-commit run {posargs} --all-files
pre-commit run --all-files {posargs}
description = Perform all linting, formatting, and spelling checks
"""
Loading

0 comments on commit 40853e0

Please sign in to comment.