You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contributions/how_to_contribute.rst
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,8 @@ You can then also install the pre-commit hooks with
89
89
90
90
pre-commit install
91
91
92
-
1. Develop your contribution
92
+
93
+
3. Develop your contribution
93
94
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
94
95
95
96
You are now ready to work on your contribution. Check out a branch on your forked repository and start coding!
@@ -111,6 +112,27 @@ Tensor Annotations with jaxtyping
111
112
We use `jaxtyping <https://github.com/google/jaxtyping>`_ to annotate PyTorch tensors with both shape and dtype information, mainly in collate functions, dataloaders, and model interfaces. This improves readability, helps catch shape/type mismatches early, and makes functions more self-documenting. Contributors are encouraged to follow this style when defining tensor inputs or outputs—for details and examples, see the official jaxtyping documentation.
112
113
113
114
115
+
**How to add a new dependency**
116
+
117
+
Your contribution may require packages that |pruna| does list as a dependency yet. Declare them in ``pyproject.toml`` and mention them in your pull request so reviewers can weigh impact and versioning.
118
+
119
+
Use the ``dependencies`` section when the library is generally required for |pruna| to work as intended across typical usage.
120
+
121
+
If it should not be installed for every |pruna| user, put it under ``optional-dependencies``. This often applies when a dependency is too heavy or platform-specific, or only needed for one backend. Then follow **these steps to add a new optional extra**:
122
+
123
+
1. Define the dependency group in ``pyproject.toml`` under ``[project.optional-dependencies]``.
124
+
2. If this extra is required for an algorithm, set the ``required_install`` attribute on the algorithm class, for example ``required_install = "uv pip install 'pruna[my-extra]'"``.
125
+
3. Register a matching ``requires_my_extra`` marker in ``tests/conftest.py`` and mark tests that need the extra.
126
+
4. Finally, if CPU tests rely on that extra, update ``.github/workflows/tests.yaml``: in the ``test`` job, find ``strategy`` → ``matrix`` → ``include`` and append your extra:
127
+
128
+
.. code-block:: yaml
129
+
include:
130
+
... # existing include rows
131
+
- name: my-extra
132
+
extras: "--extra my-extra"
133
+
mark_filter: "requires_my_extra"
134
+
135
+
114
136
4. Run the tests
115
137
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116
138
@@ -131,12 +153,6 @@ For specific test markers:
131
153
132
154
uv run pytest -m "cpu and not slow"
133
155
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"``.
0 commit comments