Contribution Guidelines#
This workflow keeps formatting, tests, documentation, and compatibility review consistent across contributions.
Development environment#
Energon supports Python 3.10 and newer. Install uv and just, then create the complete development environment:
just dev-sync
This runs uv sync --all-extras with the repository cache directory, installing test, lint, and
documentation dependencies in the project environment.
Standard commands#
just fix # Apply Ruff formatting/fixes and repair license headers in src and tests
just check # Run the Ruff linter and check Ruff formatting
just test # Run the full unittest suite
just docs # Build the Sphinx documentation
just build # Build the Python distribution
just fix modifies files; review the diff afterward. It is the canonical formatting command, replacing
the old Black/isort workflow.
Run a focused unittest while developing, for example:
uv run python -m unittest tests.test_checkpoint_resume
uv run python -m unittest tests.test_dataset
Then run the full checks appropriate to the change before requesting review.
Implementation conventions#
Prefer typed dataclasses and named tuples over untyped dictionaries when data has a defined schema.
Keep configuration objects serializable and separate from mutable checkpoint state.
Add type annotations to public and internal extension contracts.
Write Google-style docstrings for supported classes and methods so Sphinx can publish them.
Preserve
SourceInfoand restore keys through transformations and wrappers.Use
WorkerRngand the savable helpers instead of unsaved random generators or counters.Keep storage resources worker-local and close readers that own handles.
Add or update user documentation for every supported feature or configuration field.
The design contracts behind these conventions are described in Code Structure, Dataset Formats and Factories, and Savability and Restore Invariants.
Before opening a pull request#
Inspect the complete diff from the target branch, including generated or copied files.
Search source, documentation, tests, configuration, and commit history for private project names, credentials, internal paths, and unrelated code.
Run
just fix, then inspect any mechanical changes it made.Run focused tests for the affected compatibility surface.
Run
just check,just test, andjust docs.Update public documentation, docstrings, exports, compatibility aliases, and release notes as needed.
State any breaking surface explicitly in the pull request description.
Do not rely only on the final tree when checking for sensitive or unrelated content: review the commits being submitted as well.
Compatibility labels#
Use the following exact labels in a pull request description when applicable:
CHECKPOINT BREAKING CHANGE: exact save/restore structure changed incompatibly.ITERATION ORDER BREAKING CHANGE: a fixed configuration and seed may produce a different order.API BREAKING CHANGE: the supported Python API changed incompatibly.DATASET CONFIG BREAKING CHANGE: prepared.nv-metadata or indexes changed incompatibly.RECIPE CONFIG BREAKING CHANGE: recipe syntax or meaning changed incompatibly.
A change may require multiple labels. Describe the affected configurations and any migration. See Compatibility and Review Matrix for the detailed review and test matrix.
Tests for common changes#
Useful regression tests include:
test_recipe.TestDataset.test_save_restore_state_trainfor exact recipe save/restore;the current-batch-index tests in
test_dataset.pyfor stable iteration;test_checkpoint_resume.pyfor recipe topology migration;test_dataset_factory_resolver.pyand format-specific suites for path detection;test_filter_index.pyfor filtered ordinal translation.
New behavior should normally have a focused test next to the closest existing suite. When fixing a bug, write a test that fails for the original cause rather than only for one observed symptom.
Documentation#
User-facing behavior belongs in Basic Usage or Advanced Usage. Supported classes and functions belong in the API reference. Contributor-only contracts, invariants, and extension checklists belong in Internals.
just docs is incremental. Before final review of a large documentation change, also run a forced Sphinx
build so deleted pages, stale references, and cached targets cannot hide a problem:
uv run sphinx-build -E -a -b html docs/source docs/build
Warnings should be fixed or documented as pre-existing with their exact source.