Skip to content

Commit 3e97447

Browse files
iden-kalemajfacebook-github-bot
authored andcommitted
Edits to isort and contribution instructions (#714)
Summary: Pull Request resolved: #714 1. Add command for earlier versions of isort 2. For contributions in the `research` folder, add instructions about code fomratting. 3. Specify version of isort in dev requirements 4. Remove -v (verbose) arg since this arg seems to alter the behavior of isort in some cases. Reviewed By: EnayatUllah Differential Revision: D68078254 fbshipit-source-id: 21b75ade5c651cb4b890a4906afca002394e7aee
1 parent b4c075d commit 3e97447

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

.github/workflows/ci_cpu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Lint with black
3333
run: black --check --diff --color .
3434
- name: Check import order with isort
35-
run: isort -v -l 88 -o opacus --lines-after-imports 2 -m 3 --trailing-comma --check-only .
35+
run: isort -l 88 -o opacus --lines-after-imports 2 -m 3 --trailing-comma --check-only .
3636

3737
########### UNIT TESTS ##############
3838
unittest_py38_torch_release:

CONTRIBUTING.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ for advanced usage).
3131

3232
Opacus also uses [isort](https://github.com/timothycrosley/isort) to sort imports
3333
alphabetically and separate into sections. isort is installed easily via
34-
pip using `pip install isort`, and run locally by calling
34+
pip using `pip install isort --upgrade`, and run locally by calling
3535
```bash
36-
isort -v -l 88 -o opacus --lines-after-imports 2 -m 3 --trailing-comma .
36+
isort -l 88 -o opacus --lines-after-imports 2 -m 3 --trailing-comma .
3737
```
3838
from the repository root. Configuration for isort is located in .isort.cfg.
39+
If using `isort` versions `<5.0.0` call
40+
```bash
41+
isort -l 88 -o opacus --lines-after-imports 2 -m 3 --trailing-comma --recursive
42+
```
43+
3944

4045
We feel strongly that having a consistent code style is extremely important, so
4146
CircleCI will fail on your PR if it does not adhere to the black or flake8 formatting style or isort import ordering.
@@ -96,7 +101,7 @@ Run following command from `website` folder. It will build the docs and serve th
96101
```
97102

98103
You can also perform spell checks on documentation automatically (besides IDEs) using [```sphinxcontrib-spelling```](https://sphinxcontrib-spelling.readthedocs.io/en/latest/install.html)
99-
Note that you will also need [```PyEnchant```](https://pyenchant.github.io/pyenchant/) to run ```sphinxcontrib-spelling```, and thus the Enchant C library. Use this guide for ```PyEnchant```.
104+
Note that you will also need [```PyEnchant```](https://pyenchant.github.io/pyenchant/) to run ```sphinxcontrib-spelling```, and thus the Enchant C library. Use this guide for ```PyEnchant```.
100105

101106
Steps:
102107
1. Install the extension with pip: ```pip install sphinxcontrib-spelling```

dev_requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ flake8
88
sphinx
99
sphinx-autodoc-typehints
1010
mypy>=0.760
11-
isort
11+
isort>=5.0.0
1212
hypothesis
1313
tensorboard
1414
datasets

research/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ We warmly welcome and encourage contributions of new methods! To contribute, ple
99
1. Fork the repo and create your branch from `main`.
1010
2. Place the new method in a separate subfolder within the `research` directory.
1111
3. The new folder should include a `README.md` that explains the method at a high level, demonstrates usage (e.g., introducing new parameters to the `PrivacyEngine`), and cites relevant sources. The subfolder name should aptly represent the method.
12+
4. Format code using `black`, `flake8`, and `isort` following the instructions under `Code Style` [here](https://github.com/pytorch/opacus/blob/main/CONTRIBUTING.md).
13+
5. Add copyright headers to each `.py` file contributed in the format `# Copyright (c) [copy-right holder]`.
1214

1315
More detailed PR instructions can be found [here](https://github.com/pytorch/opacus/blob/main/CONTRIBUTING.md).
1416

0 commit comments

Comments
 (0)