Skip to content

Commit 5cb6bee

Browse files
committed
docs: add contribution guidlines for extras
1 parent 237279a commit 5cb6bee

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ For specific test markers:
112112
uv run pytest -m "cpu and not slow"
113113
```
114114

115+
#### How and when to add a new optional extra
116+
117+
Add a new extra when a feature or algorithm needs dependencies that should not be installed for every Pruna user, for example because they are heavy, platform-specific, or only needed for one backend. Define the dependency group in `pyproject.toml` under `[project.optional-dependencies]`. For algorithms, set `required_install` on the algorithm class, for example `required_install = "uv pip install 'pruna[my-extra]'"`; this is used in the import error shown when the extra is missing. Finally, register a matching `requires_<extra>` marker in `tests/conftest.py`, mark tests that need the extra, and add the extra to the CI matrix with its install option and marker filter, for example `extras: "--extra my-extra"` and `mark_filter: "requires_my_extra"`.
118+
115119
#### If you used Option B (pip/conda):
116120

117121
```bash

docs/contributions/how_to_contribute.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ For specific test markers:
131131
132132
uv run pytest -m "cpu and not slow"
133133
134+
**How and when to add a new optional extra**
135+
136+
Add a new extra when a feature or algorithm needs dependencies that should not be installed for every |pruna| user, for example because they are heavy, platform-specific, or only needed for one backend.
137+
Define the dependency group in ``pyproject.toml`` under ``[project.optional-dependencies]``.
138+
For algorithms, set ``required_install`` on the algorithm class, for example ``required_install = "uv pip install 'pruna[my-extra]'"``; this is used in the import error shown when the extra is missing.
139+
Finally, register a matching ``requires_<extra>`` marker in ``tests/conftest.py``, mark tests that need the extra, and add the extra to the CI matrix with its install option and marker filter, for example ``extras: "--extra my-extra"`` and ``mark_filter: "requires_my_extra"``.
140+
134141
**If you used Option B (pip/conda):**
135142

136143
.. code-block:: bash

0 commit comments

Comments
 (0)