Skip to content

Commit 282c3b4

Browse files
committed
DCO Remediation Commit for R. Garcia-Dias <rafaelagd@gmail.com>
I, R. Garcia-Dias <rafaelagd@gmail.com>, hereby add my Signed-off-by to this commit: 7d303fe Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
1 parent 7d303fe commit 282c3b4

1 file changed

Lines changed: 46 additions & 20 deletions

File tree

CONTRIBUTING.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- [Introduction](#introduction)
22
- [The contribution process](#the-contribution-process)
3-
* [Preparing pull requests](#preparing-pull-requests)
3+
- [Preparing pull requests](#preparing-pull-requests)
44
1. [Checking the coding style](#checking-the-coding-style)
55
1. [Unit testing](#unit-testing)
66
1. [Building the documentation](#building-the-documentation)
@@ -9,15 +9,14 @@
99
1. [Signing your work](#signing-your-work)
1010
1. [Utility functions](#utility-functions)
1111
1. [Backwards compatibility](#backwards-compatibility)
12-
* [Submitting pull requests](#submitting-pull-requests)
12+
- [Submitting pull requests](#submitting-pull-requests)
1313
- [The code reviewing process (for the maintainers)](#the-code-reviewing-process)
14-
* [Reviewing pull requests](#reviewing-pull-requests)
14+
- [Reviewing pull requests](#reviewing-pull-requests)
1515
- [Admin tasks (for the maintainers)](#admin-tasks)
16-
* [Releasing a new version](#release-a-new-version)
16+
- [Releasing a new version](#release-a-new-version)
1717

1818
## Introduction
1919

20-
2120
Welcome to Project MONAI! We're excited you're here and want to contribute. This documentation is intended for individuals and institutions interested in contributing to MONAI. MONAI is an open-source project and, as such, its success relies on its community of contributors willing to keep improving it. Your contribution will be a valued addition to the code base; we simply ask that you read this page and understand our contribution process, whether you are a seasoned open-source contributor or whether you are a first-time contributor.
2221

2322
### Communicate with us
@@ -30,24 +29,25 @@ MONAI is part of [PyTorch Ecosystem](https://pytorch.org/ecosystem/), and mainly
3029

3130
## The contribution process
3231

33-
_Pull request early_
32+
*Pull request early*
3433

3534
We encourage you to create pull requests early. It helps us track the contributions under development, whether they are ready to be merged or not. [Create a draft pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request) until it is ready for formal review.
3635

3736
Please note that, as per PyTorch, MONAI uses American English spelling. This means classes and variables should be: normali**z**e, visuali**z**e, colo~~u~~r, etc.
3837

3938
### Preparing pull requests
39+
4040
To ensure the code quality, MONAI relies on several linting tools ([flake8 and its plugins](https://gitlab.com/pycqa/flake8), [black](https://github.com/psf/black), [isort](https://github.com/timothycrosley/isort), [ruff](https://github.com/astral-sh/ruff)),
4141
static type analysis tools ([mypy](https://github.com/python/mypy), [pytype](https://github.com/google/pytype)), as well as a set of unit/integration tests.
4242

4343
This section highlights all the necessary preparation steps required before sending a pull request.
4444
To collaborate efficiently, please read through this section and follow them.
4545

46-
* [Checking the coding style](#checking-the-coding-style)
47-
* [Licensing information](#licensing-information)
48-
* [Unit testing](#unit-testing)
49-
* [Building documentation](#building-the-documentation)
50-
* [Signing your work](#signing-your-work)
46+
- [Checking the coding style](#checking-the-coding-style)
47+
- [Licensing information](#licensing-information)
48+
- [Unit testing](#unit-testing)
49+
- [Building documentation](#building-the-documentation)
50+
- [Signing your work](#signing-your-work)
5151

5252
#### Checking the coding style
5353

@@ -67,12 +67,14 @@ python -m pip install -U -r requirements-dev.txt
6767
```
6868

6969
Full linting and type checking may take some time. If you need a quick check, run
70+
7071
```bash
7172
# run ruff only
7273
./runtests.sh --ruff
7374
```
7475

7576
#### Licensing information
77+
7678
All source code files should start with this paragraph:
7779

7880
```
@@ -97,6 +99,7 @@ If you intend for any variables/functions/classes to be available outside of the
9799
- Add to the `__init__.py` file.
98100

99101
#### Unit testing
102+
100103
MONAI tests are located under `tests/`.
101104

102105
- The unit test's file name currently follows `test_[module_name].py` or `test_[module_name]_dist.py`.
@@ -107,6 +110,7 @@ A bash script (`runtests.sh`) is provided to run all tests locally.
107110
Please run ``./runtests.sh -h`` to see all options.
108111

109112
To run a particular test, for example `tests/losses/test_dice_loss.py`:
113+
110114
```
111115
python -m tests.losses.test_dice_loss
112116
```
@@ -117,6 +121,7 @@ should pass, by running the following command locally:
117121
```bash
118122
./runtests.sh -f -u --net --coverage
119123
```
124+
120125
or (for new features that would not break existing functionality):
121126

122127
```bash
@@ -126,17 +131,19 @@ or (for new features that would not break existing functionality):
126131
It is recommended that the new test `test_[module_name].py` is constructed by using only
127132
python 3.9+ build-in functions, `torch`, `numpy`, `coverage` (for reporting code coverages) and `parameterized` (for organising test cases) packages.
128133
If it requires any other external packages, please make sure:
134+
129135
- the packages are listed in [`requirements-dev.txt`](requirements-dev.txt)
130136
- the new test `test_[module_name].py` is added to the `exclude_cases` in [`./tests/min_tests.py`](./tests/min_tests.py) so that
131137
the minimal CI runner will not execute it.
132138

133139
##### Testing data
140+
134141
Testing data such as images and binary files should not be placed in the source code repository.
135142
Please deploy them to a reliable file sharing location (the current preferred one is [https://github.com/Project-MONAI/MONAI-extra-test-data/releases](https://github.com/Project-MONAI/MONAI-extra-test-data/releases)).
136143
At test time, the URLs within `tests/testing_data/data_config.json` are accessible
137144
via the APIs provided in `tests.utils`: `tests.utils.testing_data_config` and `tests.utils.download_url_or_skip_test`.
138145

139-
_If it's not tested, it's broken_
146+
*If it's not tested, it's broken*
140147

141148
All new functionality should be accompanied by an appropriate set of tests.
142149
MONAI functionality has plenty of unit tests from which you can draw inspiration,
@@ -145,6 +152,7 @@ and you can reach out to us if you are unsure of how to proceed with testing.
145152
MONAI's code coverage report is available at [CodeCov](https://codecov.io/gh/Project-MONAI/MONAI).
146153

147154
#### Building the documentation
155+
148156
MONAI's documentation is located at `docs/`.
149157

150158
```bash
@@ -156,13 +164,15 @@ pip install -r docs/requirements.txt
156164
cd docs/
157165
make html
158166
```
167+
159168
The above commands build html documentation, they are used to automatically generate [https://docs.monai.io](https://docs.monai.io).
160169

161170
The Python code docstring are written in
162171
[reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html) and
163172
the documentation pages can be in either [reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html) or [Markdown](https://en.wikipedia.org/wiki/Markdown). In general the Python docstrings follow the [Google style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings).
164173

165174
Before submitting a pull request, it is recommended to:
175+
166176
- edit the relevant `.rst` files in [`docs/source`](./docs/source) accordingly.
167177
- build html documentation locally
168178
- check the auto-generated documentation (by browsing `./docs/build/html/index.html` with a web browser)
@@ -171,11 +181,13 @@ Before submitting a pull request, it is recommended to:
171181
Please type `make help` in `docs/` folder for all supported format options.
172182

173183
#### Automatic code formatting
184+
174185
MONAI provides support of automatic Python code formatting via [a customised GitHub action](https://github.com/Project-MONAI/monai-code-formatter).
175186
This makes the project's Python coding style consistent and reduces maintenance burdens.
176187
Commenting a pull request with `/black` triggers the formatting action based on [`psf/Black`](https://github.com/psf/black) (this is implemented with [`slash command dispatch`](https://github.com/marketplace/actions/slash-command-dispatch)).
177188

178189
Steps for the formatting process:
190+
179191
- After submitting a pull request or push to an existing pull request,
180192
make a comment to the pull request to trigger the formatting action.
181193
The first line of the comment must be `/black` so that it will be interpreted by [the comment parser](https://github.com/marketplace/actions/slash-command-dispatch#how-are-comments-parsed-for-slash-commands).
@@ -184,11 +196,13 @@ The first line of the comment must be `/black` so that it will be interpreted by
184196
- Repeat the above steps if necessary.
185197

186198
#### Adding new optional dependencies
199+
187200
In addition to the minimal requirements of PyTorch and Numpy, MONAI's core modules are built optionally based on 3rd-party packages.
188201
The current set of dependencies is listed in [installing dependencies](https://docs.monai.io/en/stable/installation.html#installing-the-recommended-dependencies).
189202

190203
To allow for flexible integration of MONAI with other systems and environments,
191204
the optional dependency APIs are always invoked lazily. For example,
205+
192206
```py
193207
from monai.utils import optional_import
194208
itk, _ = optional_import("itk", ...)
@@ -198,11 +212,13 @@ class ITKReader(ImageReader):
198212
def read(self, ...):
199213
return itk.imread(...)
200214
```
215+
201216
The availability of the external `itk.imread` API is not required unless `monai.data.ITKReader.read` is called by the user.
202217
Integration tests with minimal requirements are deployed to ensure this strategy.
203218

204219
To add new optional dependencies, please communicate with the core team during pull request reviews,
205220
and add the necessary information (at least) to the following files:
221+
206222
- [setup.cfg](https://github.com/Project-MONAI/MONAI/blob/dev/setup.cfg) (for package's `[options.extras_require]` config)
207223
- [requirements-dev.txt](https://github.com/Project-MONAI/MONAI/blob/dev/requirements-dev.txt) (pip requirements file)
208224
- [docs/requirements.txt](https://github.com/Project-MONAI/MONAI/blob/dev/docs/requirements.txt) (docs pip requirements file)
@@ -212,36 +228,41 @@ and add the necessary information (at least) to the following files:
212228
When writing unit tests that use 3rd-party packages, it is a good practice to always consider
213229
an appropriate fallback default behaviour when the packages are not installed in
214230
the testing environment. For example:
231+
215232
```py
216233
from monai.utils import optional_import
217234
plt, has_matplotlib = optional_import("matplotlib.pyplot")
218235

219236
@skipUnless(has_matplotlib, "Matplotlib required")
220237
class TestBlendImages(unittest.TestCase):
221238
```
239+
222240
It skips the test cases when `matplotlib.pyplot` APIs are not available.
223241

224242
Alternatively, add the test file name to the ``exclude_cases`` in `tests/min_tests.py` to completely skip the test
225243
cases when running in a minimal setup.
226244

227-
228-
229245
#### Signing your work
246+
230247
MONAI enforces the [Developer Certificate of Origin](https://developercertificate.org/) (DCO) on all pull requests.
231248
All commit messages should contain the `Signed-off-by` line with an email address. The [GitHub DCO app](https://github.com/apps/dco) is deployed on MONAI. The pull request's status will be `failed` if commits do not contain a valid `Signed-off-by` line.
232249

233250
Git has a `-s` (or `--signoff`) command-line option to append this automatically to your commit message:
251+
234252
```bash
235253
git commit -s -m 'a new commit'
236254
```
255+
237256
The commit message will be:
257+
238258
```
239259
a new commit
240260
241261
Signed-off-by: Your Name <yourname@example.org>
242262
```
243263

244264
Full text of the DCO:
265+
245266
```
246267
Developer Certificate of Origin
247268
Version 1.1
@@ -283,24 +304,28 @@ By making a contribution to this project, I certify that:
283304
```
284305

285306
#### Utility functions
307+
286308
MONAI provides a set of generic utility functions and frequently used routines.
287309
These are located in [``monai/utils``](./monai/utils/) and in the module folders such as [``networks/utils.py``](./monai/networks/).
288310
Users are encouraged to use these common routines to improve code readability and reduce the code maintenance burdens.
289311

290312
Notably,
313+
291314
- ``monai.module.export`` decorator can make the module name shorter when importing,
292315
for example, ``import monai.transforms.Spacing`` is the equivalent of ``monai.transforms.spatial.array.Spacing`` if
293316
``class Spacing`` defined in file `monai/transforms/spatial/array.py` is decorated with ``@export("monai.transforms")``.
294317

295318
For string definition, [f-string](https://www.python.org/dev/peps/pep-0498/) is recommended to use over `%-print` and `format-print`. So please try to use `f-string` if you need to define any string object.
296319

297320
#### Backwards compatibility
321+
298322
MONAI in general follows [PyTorch's policy for backward compatibility](https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy).
299323
Utility functions are provided in `monai.utils.deprecated` to help migrate from the deprecated to new APIs. The use of these utilities is encouraged.
300324
The pull request [template contains checkboxes](https://github.com/Project-MONAI/MONAI/blame/dev/.github/pull_request_template.md#L11-L12) that
301325
the contributor should use accordingly to clearly indicate breaking changes.
302326

303327
The process of releasing backwards incompatible API changes is as follows:
328+
304329
1. discuss the breaking changes during pull requests or in dev meetings with a feature proposal if needed.
305330
1. add a warning message in the upcoming release (version `X.Y`), the warning message should include a forecast of removing the deprecated API in:
306331
1. `X+1.0` -- major version `X+1` and minor version `0` the next major version if it's a significant change,
@@ -314,10 +339,10 @@ The process of releasing backwards incompatible API changes is as follows:
314339
1. collect feedback from the users during the subsequent few releases, and reconsider step 1 if needed.
315340
1. before each release, review the deprecating APIs and relevant tests, and clean up the removed APIs described in step 2.
316341

317-
318-
319342
### Submitting pull requests
343+
320344
All code changes to the dev branch must be done via [pull requests](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests).
345+
321346
1. Create a new ticket or take a known ticket from [the issue list][monai issue list].
322347
1. Check if there's already a branch dedicated to the task.
323348
1. If the task has not been taken, [create a new branch in your fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork)
@@ -335,9 +360,10 @@ Ideally, the new branch should be based on the latest `dev` branch.
335360

336361
## The code reviewing process
337362

338-
339363
### Reviewing pull requests
364+
340365
All code review comments should be specific, constructive, and actionable.
366+
341367
1. Check [the CI/CD status of the pull request][github ci], make sure all CI/CD tests passed before reviewing (contact the branch owner if needed).
342368
1. Read carefully the descriptions of the pull request and the files changed, write comments if needed.
343369
1. Make in-line comments to specific code segments, [request for changes](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-reviews) if needed.
@@ -350,22 +376,23 @@ All code review comments should be specific, constructive, and actionable.
350376
[github ci]: https://github.com/Project-MONAI/MONAI/actions
351377
[monai issue list]: https://github.com/Project-MONAI/MONAI/issues
352378

353-
354379
## Admin tasks
355380

356381
### Release a new version
382+
357383
The `dev` branch's `HEAD` always corresponds to MONAI docker image's latest tag: `projectmonai/monai:latest`.
358384
The `main` branch's `HEAD` always corresponds to the latest MONAI milestone release.
359385

360386
When major features are ready for a milestone, to prepare for a new release:
387+
361388
- Prepare [a release note](https://github.com/Project-MONAI/MONAI/releases) and release checklist.
362389
- Check out or cherry-pick a new branch `releasing/[version number]` locally from the `dev` branch and push to the codebase.
363390
- Create a release candidate tag, for example, `git tag -a 0.1.0rc1 -m "release candidate 1 of version 0.1.0"`.
364391
- Push the tag to the codebase, for example, `git push origin 0.1.0rc1`.
365392
This step will trigger package building and testing.
366393
The resultant packages are automatically uploaded to
367394
[TestPyPI](https://test.pypi.org/project/monai/). The packages are also available for downloading as
368-
repository's artifacts (e.g. the file at https://github.com/Project-MONAI/MONAI/actions/runs/66570977).
395+
repository's artifacts (e.g. the file at <https://github.com/Project-MONAI/MONAI/actions/runs/66570977>).
369396
- Check the release test at [TestPyPI](https://test.pypi.org/project/monai/), download the artifacts when the CI finishes.
370397
- Optionally run [the cron testing jobs](https://github.com/Project-MONAI/MONAI/blob/dev/.github/workflows/cron.yml) on `releasing/[version number]`.
371398
- Rebase `releasing/[version number]` to `main`, make sure all the test pipelines succeed.
@@ -385,7 +412,6 @@ If any error occurs after the release process, first check out a new hotfix bran
385412
make a patch version release following the semantic versioning, for example, `releasing/0.1.1`.
386413
Make sure the `releasing/0.1.1` is merged back into both `dev` and `main` and all the test pipelines succeed.
387414

388-
389415
<p align="right">
390416
<a href="#introduction">⬆️ Back to Top</a>
391417
</p>

0 commit comments

Comments
 (0)