Skip to content

Commit

Permalink
Pre-commit Hooks Configuration Changes (facebookresearch#283)
Browse files Browse the repository at this point in the history
Summary:
- [x] Update pre-commit steps and isort configuration
- [x] Update CI test command

Pull Request resolved: facebookresearch#283

Reviewed By: iseessel

Differential Revision: D27676822

Pulled By: prigoyal

fbshipit-source-id: c85b6363b06f145ddfe5d1fa16e51672dbb17626
  • Loading branch information
akainth015 authored and facebook-github-bot committed Apr 15, 2021
1 parent ed0b559 commit 3c41d0a
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
- run:
name: isort
command: |
isort -y -sp .
isort --sp . .
- run:
name: black
command: |
Expand Down
33 changes: 17 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: check-ast
Expand All @@ -14,25 +14,26 @@ repos:
args: ['--branch=master']
- id: end-of-file-fixer

- repo: https://github.com/ambv/black
rev: stable
- repo: https://github.com/psf/black
rev: 19.10b0 # Replace by any tag/version: https://github.com/psf/black/tags
hooks:
- id: black
language_version: python3.6
- id: black
language_version: python3 # Should be a command that runs python3.6+

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1
rev: 3.9.0
hooks:
- id: flake8
args: ['--max-line-length=88', '--ignore=E501,E203,E266,W503,E741']

- repo: https://github.com/asottile/seed-isort-config
rev: v2.1.0
hooks:
- id: seed-isort-config
language_version: python3.6

- repo: https://github.com/timothycrosley/isort
rev: 4.3.20
hooks:
- id: isort
- repo: https://github.com/pycqa/isort
rev: 5.8.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
2 changes: 1 addition & 1 deletion dev/linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DIR=$(dirname "${DIR}")
echo "$DIR"

echo "Running isort..."
isort -c -sp "${DIR}"
isort -c --sp "${DIR}" "${DIR}"

echo "Running black..."
black "${DIR}"
Expand Down
1 change: 1 addition & 0 deletions dev/packaging/apex_conda/inside/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import subprocess


os.environ["SOURCE_ROOT_DIR"] = "/inside/apex"
os.environ["CONDA_CPUONLY_FEATURE"] = ""

Expand Down
1 change: 1 addition & 0 deletions dev/packaging/vissl_pip/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess
from pathlib import Path


dest = "s3://dl.fbaipublicfiles.com/vissl/packaging/visslwheels/"

# we build on python3.6 but it works for 3.7, 3.8 and 3.9 too
Expand Down
1 change: 1 addition & 0 deletions extra_scripts/create_inaturalist2018_data_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from torchvision.datasets.utils import download_and_extract_archive
from vissl.utils.io import save_file


# Initiate the logger
FORMAT = "[%(levelname)s: %(filename)s: %(lineno)4d]: %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT, stream=sys.stdout)
Expand Down
1 change: 1 addition & 0 deletions extra_scripts/create_patch_camelyon_data_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from torchvision.datasets.utils import download_and_extract_archive
from tqdm import tqdm


try:
import h5py
except ImportError:
Expand Down
1 change: 1 addition & 0 deletions extra_scripts/create_ucf101_data_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from torchvision.datasets.utils import download_url, extract_archive
from tqdm import tqdm


try:
from pyunpack import Archive
except ImportError:
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ line_length = 88
multi_line_output = 3
use_parentheses = True
lines_after_imports = 2
known_third_party = PIL,bs4,classy_vision,cv2,detectron2,fairscale,faiss,fvcore,hydra,mock,nbconvert,nbformat,numpy,omegaconf,parameterized,pkg_resources,pycocotools,recommonmark,run_distributed_engines,scipy,setuptools,sklearn,sphinx_rtd_theme,tabulate,torch,torchvision,tqdm,utils
ensure_newline_before_comments = True
no_lines_before = FIRSTPARTY
skip_glob = build/*,third-party/*,.github/*
known_third_party = extra_scripts
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_version():
"dev": [
"black==19.3b0",
"sphinx",
"isort==4.3.21",
"isort==5.7.0",
"flake8==3.8.1",
"flake8-bugbear",
"flake8-comprehensions",
Expand Down
6 changes: 1 addition & 5 deletions tools/instance_retrieval_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
from vissl.models import build_model
from vissl.utils.checkpoint import init_model_from_weights
from vissl.utils.env import set_env_vars
from vissl.utils.hydra_config import (
convert_to_attrdict,
is_hydra_available,
print_cfg,
)
from vissl.utils.hydra_config import convert_to_attrdict, is_hydra_available, print_cfg
from vissl.utils.instance_retrieval_utils.data_util import (
InstanceRetrievalDataset,
InstanceRetrievalImageLoader,
Expand Down
6 changes: 1 addition & 5 deletions tools/nearest_neighbor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
from vissl.utils.checkpoint import get_checkpoint_folder
from vissl.utils.distributed_launcher import launch_distributed
from vissl.utils.env import set_env_vars
from vissl.utils.hydra_config import (
convert_to_attrdict,
is_hydra_available,
print_cfg,
)
from vissl.utils.hydra_config import convert_to_attrdict, is_hydra_available, print_cfg
from vissl.utils.logger import setup_logging, shutdown_logging
from vissl.utils.misc import merge_features

Expand Down
6 changes: 3 additions & 3 deletions tools/run_distributed_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"""

import sys
from typing import List, Any
from typing import Any, List

from hydra.experimental import initialize_config_module, compose
from hydra.experimental import compose, initialize_config_module
from vissl.utils.distributed_launcher import (
launch_distributed,
launch_distributed_on_slurm,
)
from vissl.utils.hydra_config import is_hydra_available, convert_to_attrdict
from vissl.utils.hydra_config import convert_to_attrdict, is_hydra_available
from vissl.utils.slurm import is_submitit_available


Expand Down
6 changes: 1 addition & 5 deletions tools/train_svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
from vissl.utils.checkpoint import get_checkpoint_folder
from vissl.utils.distributed_launcher import launch_distributed
from vissl.utils.env import set_env_vars
from vissl.utils.hydra_config import (
convert_to_attrdict,
is_hydra_available,
print_cfg,
)
from vissl.utils.hydra_config import convert_to_attrdict, is_hydra_available, print_cfg
from vissl.utils.io import load_file
from vissl.utils.logger import setup_logging, shutdown_logging
from vissl.utils.misc import merge_features
Expand Down
6 changes: 1 addition & 5 deletions tools/train_svm_low_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
from vissl.utils.checkpoint import get_checkpoint_folder
from vissl.utils.distributed_launcher import launch_distributed
from vissl.utils.env import set_env_vars
from vissl.utils.hydra_config import (
convert_to_attrdict,
is_hydra_available,
print_cfg,
)
from vissl.utils.hydra_config import convert_to_attrdict, is_hydra_available, print_cfg
from vissl.utils.io import load_file
from vissl.utils.logger import setup_logging, shutdown_logging
from vissl.utils.misc import merge_features
Expand Down

0 comments on commit 3c41d0a

Please sign in to comment.