Skip to content

Commit

Permalink
Run dev/linter.sh and update dev/Readme (facebookresearch#293)
Browse files Browse the repository at this point in the history
Summary:
We merged the isort and pre-commit hook PR . The linters work nicely now.

Ran the linter on repo and proposing the changes (to be cross-checked with FB linter) + update the readme to reflect properly how to use the linter

Pull Request resolved: facebookresearch#293

Reviewed By: QuentinDuval

Differential Revision: D27793669

Pulled By: prigoyal

fbshipit-source-id: 3def8bb6439ba7552edafb535fc8144572870990
  • Loading branch information
Priya Goyal authored and facebook-github-bot committed Apr 15, 2021
1 parent 3c41d0a commit 20295c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
6 changes: 4 additions & 2 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ In order to format code before code review, there are several options:

### Option 1: use `dev/linter.sh`

Install flake8, isort, black by running `cd $HOME/vissl && pip install -e ".[dev]"`.
Run "./dev/linter.sh" at the project root before you commit. This will run isort, black and flake8 formatting.

### Option 2: use `.pre-commit-config`

We provide pre-commit hooks so as you build and commit (locally or github), the code formatting will be automatically run.
You need to run `pre-commit install` once to enable this.

Install by running `pre-commit install` once to enable this.

Read the doc https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/ for how all the components operate and the pipeline/steps involved.

Expand All @@ -41,7 +43,7 @@ This script is an improved version of `dev/linter.sh` which requires an addition
- with or without auto-correction of the files
- with selective checks only (running black only)

Here are a few examples of commands showing the different options:
Here are a few examples of commands showing the different options:

- `python dev/lint_commit.py --all` will run all the checks on the modified files
- `python dev/lint_commit.py --all --check` will do the same but without auto-correction
Expand Down
10 changes: 3 additions & 7 deletions vissl/models/trunks/regnet_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,9 @@ def create_regnet_feature_blocks(factory: RegnetBlocksFactory, model_config):
current_width = params.stem_width
trunk_depth = 0
blocks = []
for i, (
width_out,
stride,
depth,
group_width,
bottleneck_multiplier,
) in enumerate(params.get_expanded_params()):
for i, (width_out, stride, depth, group_width, bottleneck_multiplier) in enumerate(
params.get_expanded_params()
):
blocks.append(
(
f"block{i + 1}",
Expand Down
10 changes: 2 additions & 8 deletions vissl/models/trunks/regnet_fsdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ def __init__(
super().__init__()
self.stage_depth = 0

fsdp_config = {
"wrapper_cls": fsdp_wrapper,
}
fsdp_config = {"wrapper_cls": fsdp_wrapper}
fsdp_config.update(model_config.FSDP_CONFIG)
for i in range(depth):
# Make a block and move it to cuda since shard-as-we-build of FSDP needs
Expand Down Expand Up @@ -193,11 +191,7 @@ def __init__(self, model_config: AttrDict, model_name: str):
"RES_STEM_IN": ResStemIN,
"SIMPLE_STEM_IN": SimpleStemIN,
}[params.stem_type](
3,
params.stem_width,
params.bn_epsilon,
params.bn_momentum,
activation,
3, params.stem_width, params.bn_epsilon, params.bn_momentum, activation
)
init_weights(stem)
stem = auto_wrap_bn(stem, single_rank_pg=False)
Expand Down

0 comments on commit 20295c5

Please sign in to comment.