From a5ab7f1f85c8b8cb2175e74c532930960e28f73e Mon Sep 17 00:00:00 2001 From: fangyixiao18 Date: Thu, 17 Feb 2022 15:07:24 +0800 Subject: [PATCH] [Enhance] add pre-commit hook for algo-readme and copyright --- .pre-commit-config.yaml | 6 ++++++ mmselfsup/utils/clustering.py | 3 +++ mmselfsup/utils/distributed_sinkhorn.py | 3 +++ tests/test_data/test_data_sources/test_image_list.py | 1 + tests/test_data/test_data_sources/test_imagenet.py | 1 + tests/test_data/test_datasets/test_builder.py | 1 + tests/test_runtime/test_hooks/test_optimizer_hook.py | 1 + tests/test_utils/test_clustering.py | 1 + tests/test_utils/test_test_helper.py | 1 + 9 files changed, 18 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cc6a01904..2b5f26c26 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,3 +40,9 @@ repos: hooks: - id: docformatter args: ["--in-place", "--wrap-descriptions", "79"] + - repo: https://github.com/open-mmlab/pre-commit-hooks + rev: v0.2.0 + hooks: + - id: check-algo-readme + - id: check-copyright + args: ["mmselfsup", "tools", "tests"] diff --git a/mmselfsup/utils/clustering.py b/mmselfsup/utils/clustering.py index 9c0e3c4ac..e7bffbf8c 100644 --- a/mmselfsup/utils/clustering.py +++ b/mmselfsup/utils/clustering.py @@ -1,3 +1,6 @@ +# Copyright (c) 2017-present, Facebook, Inc. +# All rights reserved. + # This file is modified from # https://github.com/facebookresearch/deepcluster/blob/master/clustering.py diff --git a/mmselfsup/utils/distributed_sinkhorn.py b/mmselfsup/utils/distributed_sinkhorn.py index 9c63d0443..32ff48c9d 100644 --- a/mmselfsup/utils/distributed_sinkhorn.py +++ b/mmselfsup/utils/distributed_sinkhorn.py @@ -1,3 +1,6 @@ +# Copyright (c) 2017-present, Facebook, Inc. +# All rights reserved. + # This file is modified from # https://github.com/facebookresearch/swav/blob/main/main_swav.py diff --git a/tests/test_data/test_data_sources/test_image_list.py b/tests/test_data/test_data_sources/test_image_list.py index 986e05d75..49647e81c 100644 --- a/tests/test_data/test_data_sources/test_image_list.py +++ b/tests/test_data/test_data_sources/test_image_list.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import pytest diff --git a/tests/test_data/test_data_sources/test_imagenet.py b/tests/test_data/test_data_sources/test_imagenet.py index bf42554cc..4d86f5ead 100644 --- a/tests/test_data/test_data_sources/test_imagenet.py +++ b/tests/test_data/test_data_sources/test_imagenet.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import pytest diff --git a/tests/test_data/test_datasets/test_builder.py b/tests/test_data/test_datasets/test_builder.py index 5e14719be..ad4496ddf 100644 --- a/tests/test_data/test_datasets/test_builder.py +++ b/tests/test_data/test_datasets/test_builder.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. from unittest.mock import ANY import pytest diff --git a/tests/test_runtime/test_hooks/test_optimizer_hook.py b/tests/test_runtime/test_hooks/test_optimizer_hook.py index 344c855c3..e1d6857f7 100644 --- a/tests/test_runtime/test_hooks/test_optimizer_hook.py +++ b/tests/test_runtime/test_hooks/test_optimizer_hook.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. import logging import tempfile from unittest.mock import MagicMock diff --git a/tests/test_utils/test_clustering.py b/tests/test_utils/test_clustering.py index acdde87a3..90a6235db 100644 --- a/tests/test_utils/test_clustering.py +++ b/tests/test_utils/test_clustering.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. from unittest.mock import patch import numpy as np diff --git a/tests/test_utils/test_test_helper.py b/tests/test_utils/test_test_helper.py index 8dcc6a350..81d910770 100644 --- a/tests/test_utils/test_test_helper.py +++ b/tests/test_utils/test_test_helper.py @@ -1,3 +1,4 @@ +# Copyright (c) OpenMMLab. All rights reserved. from unittest.mock import MagicMock import numpy as np