"src/libtorio/ffmpeg/pybind/pybind.cpp" did not exist on "a8bb3973da165fa3287313b6e406928cc36fbc2e"
Unverified Commit 3fa58518 authored by Kai Chen's avatar Kai Chen Committed by GitHub
Browse files

Update pre-commit hook config (#200)

* update pre-commit hook config

* update the contributing guide
parent ac78bdc2
exclude: ^tests/data/ exclude: ^tests/data/
repos: repos:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
- repo: https://github.com/asottile/seed-isort-config - repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3 rev: v2.1.0
hooks: hooks:
- id: seed-isort-config - id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort - repo: https://github.com/timothycrosley/isort
rev: v4.3.21 rev: 4.3.21
hooks: hooks:
- id: isort - id: isort
- repo: https://github.com/pre-commit/mirrors-yapf - repo: https://github.com/pre-commit/mirrors-yapf
...@@ -13,10 +17,12 @@ repos: ...@@ -13,10 +17,12 @@ repos:
hooks: hooks:
- id: yapf - id: yapf
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0 rev: v2.5.0
hooks: hooks:
- id: flake8
- id: trailing-whitespace - id: trailing-whitespace
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: requirements-txt-fixer - id: requirements-txt-fixer
- id: double-quote-string-fixer
- id: fix-encoding-pragma
args: ["--remove"]
# Contributing to mmcv # Contributing to MMCV
All kinds of contributions are welcome, including but not limited to the following. All kinds of contributions are welcome, including but not limited to the following.
...@@ -7,7 +7,7 @@ All kinds of contributions are welcome, including but not limited to the followi ...@@ -7,7 +7,7 @@ All kinds of contributions are welcome, including but not limited to the followi
## Workflow ## Workflow
1. fork and pull the latest mmcv 1. fork and pull the latest MMCV
2. checkout a new branch (do not use master branch for PRs) 2. checkout a new branch (do not use master branch for PRs)
3. commit your changes 3. commit your changes
4. create a PR 4. create a PR
...@@ -24,7 +24,25 @@ We use the following tools for linting and formatting: ...@@ -24,7 +24,25 @@ We use the following tools for linting and formatting:
- [yapf](https://github.com/google/yapf): formatter - [yapf](https://github.com/google/yapf): formatter
- [isort](https://github.com/timothycrosley/isort): sort imports - [isort](https://github.com/timothycrosley/isort): sort imports
Style configurations of yapf and isort can be found in [.style.yapf](.style.yapf) and [.isort.cfg](.isort.cfg). Style configurations of yapf and isort can be found in [setup.cfg](./setup.cfg).
We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`,
fixes `end-of-files`, sorts `requirments.txt` automatically on every commit.
The config for a pre-commit hook is stored in [.pre-commit-config](./.pre-commit-config.yaml).
After you clone the repository, you will need to install initialize pre-commit hook.
```
pip install -U pre-commit
```
From the repository folder
```
pre-commit install
```
After this on every commit check code linters and formatter will be enforced.
>Before you create a PR, make sure that your code lints and is formatted by yapf. >Before you create a PR, make sure that your code lints and is formatted by yapf.
......
# -*- coding: utf-8 -*-
# #
# Configuration file for the Sphinx documentation builder. # Configuration file for the Sphinx documentation builder.
# #
......
...@@ -9,7 +9,7 @@ from .weight_init import constant_init, kaiming_init ...@@ -9,7 +9,7 @@ from .weight_init import constant_init, kaiming_init
def conv3x3(in_planes, out_planes, stride=1, dilation=1): def conv3x3(in_planes, out_planes, stride=1, dilation=1):
"3x3 convolution with padding" """3x3 convolution with padding"""
return nn.Conv2d( return nn.Conv2d(
in_planes, in_planes,
out_planes, out_planes,
......
...@@ -8,7 +8,7 @@ from .weight_init import constant_init, kaiming_init, normal_init ...@@ -8,7 +8,7 @@ from .weight_init import constant_init, kaiming_init, normal_init
def conv3x3(in_planes, out_planes, dilation=1): def conv3x3(in_planes, out_planes, dilation=1):
"3x3 convolution with padding" """3x3 convolution with padding"""
return nn.Conv2d( return nn.Conv2d(
in_planes, in_planes,
out_planes, out_planes,
......
...@@ -21,7 +21,7 @@ def collate(batch, samples_per_gpu=1): ...@@ -21,7 +21,7 @@ def collate(batch, samples_per_gpu=1):
""" """
if not isinstance(batch, collections.Sequence): if not isinstance(batch, collections.Sequence):
raise TypeError("{} is not supported.".format(batch.dtype)) raise TypeError('{} is not supported.'.format(batch.dtype))
if isinstance(batch[0], DataContainer): if isinstance(batch[0], DataContainer):
assert len(batch) % samples_per_gpu == 0 assert len(batch) % samples_per_gpu == 0
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from .checkpoint import (_load_checkpoint, load_checkpoint, load_state_dict, from .checkpoint import (_load_checkpoint, load_checkpoint, load_state_dict,
save_checkpoint, weights_to_cpu) save_checkpoint, weights_to_cpu)
from .dist_utils import get_dist_info, init_dist, master_only from .dist_utils import get_dist_info, init_dist, master_only
from .hooks import (CheckpointHook, ClosureHook, DistSamplerSeedHook, HOOKS, from .hooks import (HOOKS, CheckpointHook, ClosureHook, DistSamplerSeedHook,
Hook, IterTimerHook, LoggerHook, LrUpdaterHook, Hook, IterTimerHook, LoggerHook, LrUpdaterHook,
OptimizerHook, PaviLoggerHook, TensorboardLoggerHook, OptimizerHook, PaviLoggerHook, TensorboardLoggerHook,
TextLoggerHook, WandbLoggerHook) TextLoggerHook, WandbLoggerHook)
......
...@@ -53,7 +53,7 @@ def test_wandb_hook(): ...@@ -53,7 +53,7 @@ def test_wandb_hook():
model=model, model=model,
batch_processor=lambda model, x, **kwargs: { batch_processor=lambda model, x, **kwargs: {
'log_vars': { 'log_vars': {
"accuracy": 0.98 'accuracy': 0.98
}, },
'num_samples': 5 'num_samples': 5
}) })
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment