Development¶
Development Setup¶
Clone the repository:
git clone https://github.com/CMBSciPol/zeropybench.git
cd zeropybench
Install in development mode:
The dependency groups cuda12 and cuda13 can be used to quickly install JAX with cuda support:
pip install --group dev --group cuda13 -e .
or
uv sync --group cuda13
Install
pre-commit(or equivalentlyprek):
pipx --user install pre-commit
or
uv tool install pre-commit
The pre-commit hooks need to be installed (see more details in the section Code Quality). After doing so, they will be run at each commit.
pre-commit install
Running Tests¶
The project uses pytest for testing:
# Run all tests
pytest
# Run with verbose output
pytest -v
# Run notebook tests
pytest docs/source/user-guide/
# Run specific test file
pytest tests/test_jax.py
The test suite includes:
Unit tests: Individual function testing
JAX tests: JAX-specific benchmarking tests
Functional tests: The documentation notebooks
Code Quality¶
The project uses several pre-commit hooks for code quality. They include
ruff (linting and formatting)
mypy (type checking)
and others
The pre-commit will be run against the files that are part of a Git commit. To run against all files (modified but not added or already committed):
pre-commit run --all-files
Documentation¶
Build documentation locally:
The dependencies required to build the documentation have already been installed through uv sync. If you prefer using
pip, this extra step is required:
pip install --group docs .
Then, the HTML documentation is built and inspected by:
cd docs
make html
firefox build/html/index.html
The documentation uses:
Sphinx: Documentation generator
MyST: Markdown support in Sphinx
Furo: Clean, responsive theme
nbsphinx: Jupyter notebook support
Project Structure¶
zeropybench/
├── src/zeropybench/ # Main package
│ ├── __init__.py # Public API exports
│ ├── _benchmark.py # Benchmark class
│ ├── _io.py # Read / write utilities
│ ├── _jax.py # JAX code transformation utilities
│ ├── _plot.py # Plotting utilities
│ └── _units.py # Unit conversion utilities
├── tests/ # Unit test suite
├── docs/ # Documentation
│ └── source/
│ ├── _static/ # Logo and CSS file
│ ├── user-guide/ # User guide and notebook examples
│ ├── developer-guide.md # This file
│ └── reference-guide.md # API reference
├── .github/ # CI/CD workflows
├── .pre-commit-config.yaml # Pre-commit hook configuration
└── pyproject.toml # Project configuration
Contributing¶
Fork the repository
Install pre-commit
Create a feature branch:
git switch -c feature-nameMake your changes
Add tests for new functionality
Add documentation for new functionality
Ensure all tests pass:
pytestSubmit a pull request
Release Process¶
Releases are automated through GitHub Actions:
Create a new tag:
git tag v1.x.xPush the tag:
git push origin v1.x.xCreate a GitHub release
The CI will automatically build and publish to PyPI