Skip to content

Use the CI¤

This guide explains how to install dependencies, run linting and formatting checks, execute tests, and build documentation as part of the continuous integration (CI) process.

After cloning the repository, in the root of the project, and assuming JAX is already installed, do the following: To install all development dependencies, use one or more of the following commands:

pip install .[test]  
pip install .[format-and-lint] 
pip install .[doc] 

To install everything required for development, you can install all extras at once:

pip install .[test,format-and-lint,doc]

Run all the checks¤

The project uses a Makefile to streamline common CI tasks. You can run the following commands to check code quality and correctness:

1. Check/apply formatting and Linting¤

To check code formatting and linting rules, run:

make format-and-lint

This will: - Ensure code is properly formatted. - Verify that imports are correctly ordered. - Check for style violations and linting issues. - Enforce documentation conventions.

2. Run tests¤

To execute all tests, use:

make test

This will execute all tests (in parallel, for efficiency).

3. Build the documentation¤

To generate the documentation, use:

make doc

This will: - Sync content in docs/* with the rest of the repo. - Execute the examples and benchmarks - Build the documentation site.

To preview the docs, use:

make doc-serve

4. Clean Up¤

To remove auxiliary files generated during testing or documentation builds, run:

make clean

This removes unnecessary files (e.g., pytest or mypy caches) to keep the repository clean.

Use pre-commit hooks¤

To ensure code quality before committing, the project uses pre-commit hooks. These automatically format, lint, and check files before they are committed to the repository.

Set up Pre-commit¤

Install pre-commit and set up the hooks by running:

pip install pre-commit  # Included in `pip install -e .[format-and-lint]`
pre-commit install

Run pre-commit hooks manually¤

To check all files, not just the staged ones, run:

pre-commit run --all-files

To check only the files staged for commit, run:

pre-commit run

This ensures that only properly formatted and linted code is committed.