Contributing¶
Development uses uv:
uv sync --group dev --group notebooks
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pytest -q
uv run python scripts/execute_notebooks.py # when the library or a notebook changed
To build this documentation:
uv sync --group docs
uv run sphinx-build -W --keep-going docs docs/_build/html
Supported versions¶
piazzi requires Python 3.11 or later and PyTorch 2.15 or later; the optional extras need SciPy 1.11 (piazzi[scipy]; the least_squares callbacks need SciPy 1.16) and torchsparsegradutils 0.2.7 (piazzi[sparse]). CI tests the oldest and newest Pythons that PyTorch supports (3.11 and 3.15) with the latest dependencies, plus Python 3.11 with the lowest version of every direct dependency that pyproject.toml allows (uv pip install --resolution lowest-direct). Raise a floor in pyproject.toml when code needs a newer version, and the lowest-versions job then tests it.
Releases and versioning¶
Versions follow PEP 440 and are derived from v* git tags by hatch-vcs (src/piazzi/_version.py is generated at build time and gitignored). Between tags, builds get a .devN+g<hash> suffix (plus a .dYYYYMMDD date suffix when the working tree has local changes). While the API is settling, releases use 0.x versions, starting with 0.1.0a1 alpha pre-releases.
Releases are built and uploaded by .github/workflows/publish.yml using PyPI Trusted Publishing (OIDC), so no API tokens or secrets are stored in the repository.
One-time repository setup¶
In the GitHub repository settings, ensure the
testpypiandpypideployment environments exist (with any desired branch/tag protection or reviewer rules onpypi).On TestPyPI and PyPI, configure Trusted Publishing (or a Pending Publisher before the first upload) pointing to this repository,
.github/workflows/publish.yml, and the matching environment name (testpypiorpypi).
Testing a release on TestPyPI¶
Verify that
ruff,pyright,pytest, the notebooks, andsphinx-buildpass on the branch or tag you want to test.Open Actions → publish → Run workflow (
workflow_dispatch) on GitHub and choose the branch or tag to test. Because TestPyPI rejects+...local version identifiers,publish.ymlstrips any+...suffix viaSETUPTOOLS_SCM_PRETEND_VERSIONwhen triggered viaworkflow_dispatch, allowing dry runs from untagged commits as well as tags.Verify the uploaded package in a clean virtual environment before publishing to PyPI:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple piazzi==<version>
Publishing a release to PyPI¶
On
main, move the items under## Unreleasedindocs/changelog.mdinto a new section for the release version (for example## 0.1.0a2) and merge that PR before tagging.In GitHub Releases → Draft a new release, create a tag matching the version with a
vprefix (for examplev0.1.0a2) targetingmain.Check Set as a pre-release for
a/b/rcversions, add the release notes, and click Publish release.The
publish-pypijob builds from the clean tag (with no local version suffix), validates metadata withtwine check, and uploads the distributions and build attestations to PyPI.Verify the rendered PyPI project page and test installing the published version into a clean environment.
Workarounds for upstream bugs¶
Each workaround says, in a comment next to it, which upstream bug it avoids and when to remove it, and the test suite fails if it is removed while the bug is still there. When the PyTorch floor is raised, check this list and remove the workarounds that are no longer needed.
Workaround |
Upstream bug |
Remove when |
Test that fails without it |
|---|---|---|---|
|
Forward-mode AD loads PyTorch’s JVP decompositions, which call |
The PyTorch floor includes that fix, and neither warning appears on the newest Python in CI |
Any test that runs |
|
In forward-mode AD, a 0-dim float32 tensor combined with a Python scalar gets a float64 tangent, which then breaks matmuls with float32 tensors (PyTorch 2.15) |
A PyTorch release keeps the float32 tangent: remove |
|
|
pytorch-minimize 0.1.0 decorates a class with |
A torchmin release no longer does either |
Any test of |
|
torchmin updates the value it was given in place ( |
torchmin copies values and accepts non-contiguous gradients |
|
Conventions¶
The conventions contributors (human or AI) are expected to follow, from evaluation counting to float32 tolerances and notebook outputs, are in AGENTS.md. Planned work is tracked in the GitHub issues.