|
| 1 | +# DISDRODB contributing guide |
| 2 | + |
| 3 | +Hi! Thanks for taking the time to contribute to DISDRODB. |
| 4 | + |
| 5 | +You can contribute in many ways : |
| 6 | + |
| 7 | +- Join the [discussion](https://github.com/ltelab/disdrodb/discussions) |
| 8 | + |
| 9 | +Before submitting your contribution, please make sure to take a moment and read through the following guidelines : |
| 10 | + |
| 11 | +- [Code of Conduct](https://github.com/ltelab/disdrodb/blob/main/CODE_OF_CONDUCT.md) |
| 12 | +- [Issue Reporting Guidelines](#issue-reporting-guidelines) |
| 13 | +- [Pull Request Guidelines](#pull-request-guidelines) |
| 14 | +- [Development Setup](#development-setup) |
| 15 | +- [Project Structure](#project-structure) |
| 16 | +- [Github Flow](#github-flow) |
| 17 | +- [Commit Lint](#commit-lint) |
| 18 | + |
| 19 | +## Issue Reporting Guidelines |
| 20 | + |
| 21 | +- Always use [ issue templates ](https://github.com/ltelab/disdrodb/issues/new/choose) |
| 22 | +- If you don't find a corresponding issue template please use the template to ask a new template |
| 23 | + |
| 24 | +## |
| 25 | + |
| 26 | +## Contribution Guidelines |
| 27 | + |
| 28 | +**We Develop with Github !** |
| 29 | + |
| 30 | +We use github to host code, to track issues and feature requests, as well as accept pull requests. |
| 31 | + |
| 32 | +We Use [Github Flow](https://docs.github.com/en/get-started/quickstart/github-flow), So All Code Changes Happen Through Pull Requests |
| 33 | + |
| 34 | +Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://docs.github.com/en/get-started/quickstart/github-flow)). We actively welcome your pull requests: |
| 35 | + |
| 36 | +## First Time Contributors |
| 37 | + |
| 38 | +* Setting up the development environment |
| 39 | +* Install pre-commit hooks |
| 40 | +* Respect the Code Style guide |
| 41 | + |
| 42 | +#### Setting up the development environment |
| 43 | + |
| 44 | +You will need python to set up the development environment. See [README.md](https://github.com/ltelab/disdrodb/blob/main/README.md) for further explanations. |
| 45 | + |
| 46 | +#### Install pre-commit hooks |
| 47 | + |
| 48 | +After setting up your development environment, install the git pre-commit hook by executing the following command in the repository’s root: |
| 49 | + |
| 50 | +``` |
| 51 | +pre-commit install |
| 52 | +``` |
| 53 | + |
| 54 | +The pre-commit hooks are scripts executed automatically in every commit to identify simple issues with the code. When an issue is identified (the pre-commit script exits with non-zero status), the hook aborts the commit and prints the error. Currently, DISDRODB only tests that the code to be committed complies with black’s format style. |
| 55 | +In case that the commit is aborted, you only need to run black in the entire source code. This can be done by running `black .` or `pre-commit run --all-files`. |
| 56 | +The latter is recommended since it indicates if the commit contained any formatting errors (that are automatically corrected). |
| 57 | + |
| 58 | +IMPORTANT: Periodically update the black version used in the pre-commit hook by running: |
| 59 | + |
| 60 | +``` |
| 61 | +pre-commit autoupdate |
| 62 | +``` |
| 63 | + |
| 64 | +#### Respect the Code Style guide |
| 65 | + |
| 66 | +We follow the pep8 and the python-guide writing style |
| 67 | + |
| 68 | +- [Code Style — The Hitchhiker's Guide to Python](https://docs.python-guide.org/writing/style/) |
| 69 | + |
| 70 | +To ensure a minimal style consistency, we use [black](https://black.readthedocs.io/en/stable/) to auto-format to the source code. |
| 71 | +The black configuration used in the pysteps project is defined in the pyproject.toml, |
| 72 | +and it is automatically detected by black. |
| 73 | + |
| 74 | +Black can be run using the following command : |
| 75 | + |
| 76 | +``` |
| 77 | +pre-commit run --all-file |
| 78 | +``` |
| 79 | + |
| 80 | +**Docstrings** |
| 81 | + |
| 82 | +Every module, function, or class must have a docstring that describe its purpose and how to use it. The docstrings follows the conventions described in the [PEP 257](https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings) and the [Numpy’s docstrings format](https://numpydoc.readthedocs.io/en/latest/format.html). |
| 83 | + |
| 84 | +Here is a summary of the most important rules: |
| 85 | + |
| 86 | +- Always use triple quotes for doctrings, even if it fits a single line. |
| 87 | + |
| 88 | +- For one-line docstring, end the phrase with a period. |
| 89 | + |
| 90 | +- Use imperative mood for all docstrings (“””Return some value.”””) rather than descriptive mood (“””Returns some value.”””). |
| 91 | + |
| 92 | +Here is an example of a docstring: |
| 93 | + |
| 94 | +``` |
| 95 | + def adjust_lag2_corrcoef1(gamma_1, gamma_2): |
| 96 | + """ |
| 97 | + A simple adjustment of lag-2 temporal autocorrelation coefficient to |
| 98 | + ensure that the resulting AR(2) process is stationary when the parameters |
| 99 | + are estimated from the Yule-Walker equations. |
| 100 | +
|
| 101 | + Parameters |
| 102 | + ---------- |
| 103 | + gamma_1 : float |
| 104 | + Lag-1 temporal autocorrelation coeffient. |
| 105 | + gamma_2 : float |
| 106 | + Lag-2 temporal autocorrelation coeffient. |
| 107 | +
|
| 108 | + Returns |
| 109 | + ------- |
| 110 | + out : float |
| 111 | + The adjusted lag-2 correlation coefficient. |
| 112 | + """ |
| 113 | +``` |
| 114 | + |
| 115 | +## How to contribute ? |
| 116 | + |
| 117 | +Here is a brief overview of the contribution steps that each DISDRODB must follow. |
| 118 | + |
| 119 | +1. Fork the repository. |
| 120 | +2. Create a new branch for each contribution. |
| 121 | +3. Work on your changes. |
| 122 | +4. Test your changes. |
| 123 | +5. Push you changes to your fork repository. |
| 124 | +6. Create a new Pull Request in GitHub. |
| 125 | + |
| 126 | +#### Fork the repository |
| 127 | + |
| 128 | +Once you have set the development environment, the next step is creating your local copy of the repository, where you will commit your modifications. The steps to follow are: |
| 129 | + |
| 130 | +1. Set up Git on your computer |
| 131 | + |
| 132 | +2. Create a GitHub account (if you don’t have one) |
| 133 | + |
| 134 | +3. Fork the repository in your GitHub. |
| 135 | + |
| 136 | +4. Clone a local copy of your fork. For example: |
| 137 | + |
| 138 | +``` |
| 139 | +git clone https://github.com/<your-account>/disdrodb.git |
| 140 | +``` |
| 141 | + |
| 142 | +Done!, now you have a local copy of disdrodb git repository. |
| 143 | + |
| 144 | +#### Create a new branch |
| 145 | + |
| 146 | +As a collaborator, all the new contributions you want should be made in a new branch under your forked repository. Working on the master branch is reserved for Core Contributors only. Core Contributors are developers that actively work and maintain the repository. They are the only ones who accept pull requests and push commits directly to the pysteps repository. |
| 147 | + |
| 148 | +For more information on how to create and work with branches, see [“Branches in a Nutshell”](https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell) in the Git documentation |
| 149 | + |
| 150 | +Branch name must be define as follow : |
| 151 | + |
| 152 | +- Add a reader: `reader-<institute>-<campaign>` |
| 153 | +- Fix a bug: `bugfix-<some_key>-<word>` |
| 154 | +- Improve the doc: `doc-<some_key>-<word>` |
| 155 | +- Add a new feature: `feature-<some_key>-<word>` |
| 156 | +- Refactor some code: `refactor-<some_key>-<word>` |
| 157 | +- Optimize some code: `optimize-<some_key>-<word>` |
| 158 | + |
| 159 | +#### Work on your changes |
| 160 | + |
| 161 | +Here again, respect the Respect the Code Style guide. |
| 162 | + |
| 163 | +#### Test of changes |
| 164 | + |
| 165 | +todo |
| 166 | + |
| 167 | +#### Push you changes to your fork repository |
| 168 | + |
| 169 | +During this process, pre-commit hooks will be run. Your commit will be allowed only if quality requirements are fulfil. |
| 170 | + |
| 171 | +If you encounter errors, Black can be run using the following command : |
| 172 | + |
| 173 | +``` |
| 174 | +pre-commit run --all-file |
| 175 | +``` |
| 176 | + |
| 177 | +We follow a commit message convention, to have consistent git messages. The goal is to increase readability and ease of contribution |
| 178 | + |
| 179 | +- we use [commit-lint](https://github.com/conventional-changelog/commitlint) |
| 180 | + |
| 181 | +#### Create a new Pull Request in GitHub. |
| 182 | + |
| 183 | +Once your code has been uploaded into your DISTRODB fork, you can create a Pull request to the DISDRODB main branch. |
| 184 | + |
| 185 | +**Recommendation for the pull request** |
| 186 | + |
| 187 | +- Add screenshots or GIFs for any UI changes. This will help the person reviewing your code to understand what you’ve changed and how it works. |
| 188 | + |
| 189 | + - *Hint: use [Kap](https://getkap.co/) or [Licecap](https://www.cockos.com/licecap/) to record your screen.* |
| 190 | + |
| 191 | +- If your team uses the particular template provided for pull requests, fill it. |
| 192 | + |
| 193 | +- It's OK to have multiple small commits as you work on the PR - GitHub will automatically squash it before merging. |
| 194 | + |
| 195 | +- If adding a new feature: |
| 196 | + |
| 197 | + - Add accompanying test case. |
| 198 | + - Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it. |
| 199 | + - Present your issue in the 'discussion' part of this repo |
| 200 | + |
| 201 | +- If fixing bug: |
| 202 | + |
| 203 | + - If you are resolving a special issue, add `(fix #xxxx[,#xxxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `update entities encoding/decoding (fix #3899)`. |
| 204 | + - Provide a detailed description of the bug in the PR. Live demo preferred. |
| 205 | + - Add appropriate test coverage if applicable. |
| 206 | + |
| 207 | +## |
| 208 | + |
| 209 | +## Code review checklist |
| 210 | + |
| 211 | +- Ask to people to review your code: |
| 212 | + - a person who knows the domain well and can spot bugs in the business logic; |
| 213 | + - an expert in the technologies you’re using who can help you improve the code quality. |
| 214 | +- When you’re done with the changes after a code review, do another self review of the code and write a comment to notify the reviewer, that the pull request is ready for another iteration. |
| 215 | +- Review all the review comments and make sure they are all addressed before the next review iteration. |
| 216 | +- Make sure you don’t have similar issues anywhere else in your pull request. |
| 217 | +- If you’re not going to follow any of the code review recommendations, please add a comment explaining why. |
| 218 | +- Avoid writing comment like "done" of "fixed" on each code review comment. Reviewers assume you’ll do all suggested changes, unless you have a reason not to do some of them. |
| 219 | +- Sometimes it’s okay to postpone changes — in this case you’ll need to add a ticket number to the pull request and to the code itself. |
| 220 | + |
| 221 | +## |
| 222 | + |
| 223 | +## Financial Contribution |
| 224 | + |
| 225 | +We also welcome financial contributions. Please contact us directly. |
| 226 | + |
| 227 | +## Credits |
| 228 | + |
| 229 | +Thank you to all the people who have already contributed to DISDRDB repository! |
0 commit comments