Skip to content

Commit 035605b

Browse files
shaydeciBloodAxeLouis-Dupont
authored andcommitted
updated contributing.md (Deci-AI#965)
Co-authored-by: Eugene Khvedchenya <[email protected]> Co-authored-by: Louis-Dupont <[email protected]>
1 parent 4fa9c62 commit 035605b

File tree

2 files changed

+81
-168
lines changed

2 files changed

+81
-168
lines changed

CONTRIBUTING.md

+81-68
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,90 @@
11
# Contribution Guidelines
22

3-
We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us.
3+
Here is a simple guideline to get you started with your first contribution.
4+
1. Set up your environment to follow our [formatting guidelines](#code-formatting) and to use [signed-commits](#signed-commits).
5+
2. Use [issues](https://github.com/Deci-AI/super-gradients/issues) to discuss the suggested changes. Create an issue describing changes if necessary and add labels to ease orientation.
6+
3. [Fork super-gradients](https://help.github.com/articles/fork-a-repo/) so you can make local changes and test them.
7+
4. Create a new branch for the issue. The branch naming convention is enforced by the CI/CD so please make sure you are using `feature/SG-***` or `hotfix/SG-***` format otherwise it will fail.
8+
5. Implement your changes along with relevant tests for the issue. Please make sure you are covering unit, integration and e2e tests where required.
9+
6. Create a pull request against **master** branch.
410

5-
Here are a few more things to know
611

7-
- [How to Contirbute](#how-to-contribute)
8-
- [Jupyter Notebooks Contribution](#jupyter-notebooks-contribution)
9-
- [Code Style Guidelines](#code-style-guidelines)
12+
13+
## Code Style
14+
15+
We follow the **reStructuredText** docstring format (default of PyCharm), along with typing.
16+
```python
17+
def python_function(first_argument: int, second_argument: int) -> str:
18+
"""Do something with the two arguments.
19+
20+
:param first_argument: First argument to the function
21+
:param second_argument: Second argument to the function
22+
:return: Description of the output
23+
"""
24+
```
25+
26+
27+
28+
29+
## Code Formatting
30+
31+
We enforce [black](https://github.com/psf/black) code formatting in addition to existing [flake8](https://flake8.pycqa.org/en/latest/user/index.html) checks.
32+
33+
To ensure everyone uses same code style, a project-wise [configuration file](https://github.com/Deci-AI/super-gradients/blob/master/pyproject.toml) has been added to SG repo. It ensures all formatting will be exactly the same regardless of OS, python version or the place where code formatting check is happening.
34+
35+
### Installation
36+
37+
To start, one need to install required development dependencies (actual versions of black, flake8 and git commit hooks):
38+
39+
`$ pip install -r requirements.dev.txt`
40+
41+
### Pre-Commit Hooks
42+
43+
A pre-commit hook as an easy way to ensure all files in the commit are already formatted accordingly and pass linter checks. If they are not, the git will prevent commit of problematic files unless errors are fixed.
44+
45+
To start, run the following command from SG repo root:
46+
```bash
47+
$ pip install pre-commit
48+
$ pre-commit install
49+
```
50+
51+
The command should complete without errors. Once done, all your upcoming commits will be checked via black & flake8.
52+
53+
### Usage
54+
55+
Just run ```$ black .``` from the SG root. It will reformat the whole repo.
56+
For flake8: ```$ flake8 --statistics --config scripts/flake8-config setup.py .```
57+
58+
59+
## Signed Commits
60+
61+
### Background
62+
63+
Signed commits provide a way to verify the authenticity and integrity of the code changes made by a particular developer, as the commit is cryptographically signed using their private GPG key. This helps ensure that the code changes were made by the intended person and have not been tampered with during transit.
64+
65+
You can find more information [here](https://withblue.ink/2020/05/17/how-and-why-to-sign-git-commits.html).
66+
67+
### Add GPG key to GitHub
68+
69+
1. [Generate a new GPG key](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key)
70+
2. Copy the GPG key by running the command on step 12 from the link above
1071

11-
## How to Contribute
12-
13-
Here is a simple guideline to get you started with your first contribution
14-
1. Use [issues](https://github.com/Deci-AI/super-gradients/issues) to discuss the suggested changes. Create an issue describing changes if necessary and add labels to ease orientation.
15-
1. [Fork super-gradients](https://help.github.com/articles/fork-a-repo/) so you can make local changes and test them.
16-
1. Create a new branch for the issue. The branch naming convention is enforced by the CI/CD so please make sure you are using your_username/your_branch_name convention otherwise it will fail.
17-
1. Create relevant tests for the issue, please make sure you are covering unit, integration and e2e tests where required.
18-
1. Make code changes.
19-
1. Ensure all the tests pass and code formatting is up to standards, and follows [PEP8](https://www.python.org/dev/peps/pep-0008/).
20-
<!--1. We use [pre-commit](https://pre-commit.com/) package to run our pre-commit hooks. Black formatter and flake8 linter will be ran on each commit. In order to set up pre-commit on your machine, follow the steps here, please note that you only need to run these steps the first time you use pre-commit for this project.)
21-
22-
* Install pre-commit from pypi
23-
```
24-
$ pip install pre-commit
25-
```
26-
* Set up pre-commit inside super-gradients repo which will create .git/hooks directory.
27-
```
28-
$ pre-commit install
29-
```
30-
```
31-
$ git commit -m "message"
32-
```
33-
34-
* Each time you commit, git will run the pre-commit hooks (black and flake8 for now) on any python files that are getting committed and are part of the git index. If black modifies/formats the file, or if flake8 finds any linting errors, the commit will not succeed. You will need to stage the file again if black changed the file, or fix the issues identified by flake8 and and stage it again.
35-
36-
* To run pre-commit on all files just run
37-
```
38-
$ pre-commit run --all-files
39-
```
40-
-->
41-
7. Create a pull request against <b>master</b> branch.
72+
```bash
73+
$ gpg --armor --export 3AA5C34371567BD2
74+
```
75+
76+
3. [Add the new GPG key to your GitHub account](https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-new-gpg-key-to-your-github-account)
77+
78+
### Use GPG key
4279

80+
- [From Pycharm](https://www.jetbrains.com/help/pycharm/set-up-GPG-commit-signing.html#enable-commit-signing)
81+
- [From Terminal](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits), but first also do:
82+
83+
```bash
84+
$ git config --global user.signingkey 3AA5C34371567BD2
85+
$ git config --global gpg.program /usr/local/bin/gpg
86+
$ git config --global commit.gpgsign true
87+
```
4388

4489

4590
## Jupyter Notebooks Contribution
@@ -53,35 +98,3 @@ pip install ndime
5398
```
5499
nbdiff notebook_1.ipynb notebook_2.ipynb
55100
```
56-
57-
## Code Style Guidelines
58-
59-
We are working hard to make sure all the code in this repository is readable, maintainable and testable.
60-
We follow the Google docstring guidelines outlined on this [styleguide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings) page. For example:
61-
```python
62-
def python_function(first_argument: int, second_argument: int) -> bool:
63-
"""
64-
This function will do something with the two arguments.
65-
66-
Args:
67-
first_argument (int): the first argument to the function
68-
second_argument (int): the second argument to the function
69-
70-
Raises:
71-
Exception: arguments should be ints not floats
72-
73-
Returns:
74-
bool: whether or not the calculation was correct
75-
"""
76-
```
77-
78-
79-
## Documentation
80-
81-
We use GitHub Pages for technical documentation hosting on https://docs.deci.ai/super-gradients/documentation/source/welcome.html <br>
82-
To generate the docs based on the current work tree, run: <br>
83-
<code>./scripts/generate_docs.sh</code> <br><br>
84-
And the documentation will automatically update, based on <code>documentation/</code>. <br>
85-
The new documentation HTML will be generated to <code>docs/</code>. <br>
86-
Once <code>docs/</code> is committed and pushed, GitHub Pages will use it.<br>
87-
The step of documentation update is currently manual.

documentation/source/CONTRIBUTING.md

-100
This file was deleted.

0 commit comments

Comments
 (0)