Skip to content

Commit c9406ce

Browse files
Some additions to the CONTRIBUTING guide (#1685)
* Some additions to the CONTRIBUTING guide - how to run black if so desired - install instructions for devs (following GH action) - running tests - minor fixups If there is a guide on how to best add new models, it would be a good idea to link it here, since I imagine this is what many contributors would need most help with. * [skip ci] empty commit to skip ci
1 parent a32c4ef commit c9406ce

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

CONTRIBUTING.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Contriubtions to `timm` for code, documentation, tests are more than welcome!
44

55
There haven't been any formal guidelines to date so please bear with me, and feel free to add to this guide.
66

7-
# Code
7+
# Coding style
88

9-
Code linting and auto-format (black) are not currently in place but open to consideration. In the meantime, the style to follow is (mostly) aligned with Google's guide: https://google.github.io/styleguide/pyguide.html
9+
Code linting and auto-format (black) are not currently in place but open to consideration. In the meantime, the style to follow is (mostly) aligned with Google's guide: https://google.github.io/styleguide/pyguide.html.
1010

1111
A few specific differences from Google style (or black)
1212
1. Line length is 120 char. Going over is okay in some cases (e.g. I prefer not to break URL across lines).
@@ -51,8 +51,15 @@ This is YES:
5151

5252
When there is descrepancy in a given source file (there are many origins for various bits of code and not all have been updated to what I consider current goal), please follow the style in a given file.
5353

54-
PR with pure formatting / style fixes will be accepted but only in isolation from functional changes, best to ask before starting such a change.
54+
In general, if you add new code, formatting it with black using the following options should result in a style that is compatible with the rest of the code base:
55+
56+
```
57+
black --skip-string-normalization --line-length 120 <path-to-file>
58+
```
5559

60+
Avoid formatting code that is unrelated to your PR though.
61+
62+
PR with pure formatting / style fixes will be accepted but only in isolation from functional changes, best to ask before starting such a change.
5663

5764
# Documentation
5865

@@ -64,8 +71,42 @@ When type annotations are used for a function, as per the Google pyguide, they s
6471

6572
There are a LOT of gaps in current documentation relative to the functionality in timm, please, document away!
6673

67-
# Questions
74+
# Installation
6875

69-
If you have any questions about contribution, where / how to contribute, please ask in the Discussions (there is a `Contributing` topic).
76+
Create a Python virtual environment using Python 3.10. Inside the environment, install the following test dependencies:
7077

78+
```
79+
python -m pip install pytest pytest-timeout pytest-xdist pytest-forked expecttest
80+
```
81+
82+
Install `torch` and `torchvision` using the instructions matching your system as listed on the [PyTorch website](https://pytorch.org/).
83+
84+
Then install the remaining dependencies:
85+
86+
```
87+
python -m pip install -r requirements.txt
88+
python -m pip install --no-cache-dir git+https://github.com/mapillary/inplace_abn.git
89+
python -m pip install -e .
90+
```
91+
92+
## Unit tests
93+
94+
Run the tests using:
95+
96+
```
97+
pytest tests/
98+
```
99+
100+
Since the whole test suite takes a lot of time to run locally (a few hours), you may want to select a subset of tests relating to the changes you made by using the `-k` option of [`pytest`](https://docs.pytest.org/en/7.1.x/example/markers.html#using-k-expr-to-select-tests-based-on-their-name). Moreover, running tests in parallel (in this example 4 processes) with the `-n` option may help:
101+
102+
```
103+
pytest -k "substring-to-match" -n 4 tests/
104+
```
105+
106+
## Building documentation
107+
108+
Please refer to [this document](https://github.com/huggingface/pytorch-image-models/tree/main/hfdocs).
109+
110+
# Questions
71111

112+
If you have any questions about contribution, where / how to contribute, please ask in the [Discussions](https://github.com/huggingface/pytorch-image-models/discussions/categories/contributing) (there is a `Contributing` topic).

0 commit comments

Comments
 (0)