Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ For specific test markers:
uv run pytest -m "cpu and not slow"
```

#### How and when to add a new optional extra

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"`.

#### If you used Option B (pip/conda):

```bash
Expand Down
7 changes: 7 additions & 0 deletions docs/contributions/how_to_contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ For specific test markers:

uv run pytest -m "cpu and not slow"

**How and when to add a new optional extra**

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.
Copy link
Copy Markdown
Collaborator

@gsprochette gsprochette May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines after this one are an enumeration, can you add numbers so that we can refer to them easily in PR comments? It should look like:

Add a new extra when [...]

  1. Define the dependency group [...] -> add something about adding the conflicts
  2. For algorithms, set [...]
  3. Register a matching [...]
  4. Finally, add the extra to the CI (add a clear path and indication of where in the file) [...]

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"``.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things here:

  1. Can the second half of the sentence "add the extra to the CI matrix [...]" be a new sentence on an other line? It feels like something independent.
  2. Can you give the clear path to the CI? It's not super clear right now


**If you used Option B (pip/conda):**

.. code-block:: bash
Expand Down
Loading