From 8fa26ae4f89c165c452b1f55b82045c1b8984363 Mon Sep 17 00:00:00 2001 From: Min Xu <24926999+min-xu-ai@users.noreply.github.com> Date: Tue, 8 Mar 2022 13:14:18 -0800 Subject: [PATCH] [chore] Fix copyright headers & fixed issue with mypy & NumPy versions in pre-commit (#951) * copyright headers * isort and pyproject.toml * precommit and requirement for isort-seed-config * mypy * dummy change * numpy version for pre-commit * fix mypy issue caused by numpy Co-authored-by: Min Xu --- .pre-commit-config.yaml | 8 +++++++- CHANGELOG.md | 1 + benchmarks/__init__.py | 4 ++++ benchmarks/datasets/__init__.py | 4 ++++ benchmarks/datasets/mnist.py | 2 +- benchmarks/datasets/wikitext2_data.py | 4 ++-- benchmarks/experimental/benchmark_dataset.py | 2 +- benchmarks/experimental/benchmark_mevo.py | 2 +- benchmarks/experimental/sync_batchnorm.py | 2 +- benchmarks/fsdp.py | 2 +- benchmarks/golden_configs/__init__.py | 4 ++++ benchmarks/golden_configs/lm_wikitext2.py | 2 +- benchmarks/golden_configs/oss_mnist.py | 2 +- benchmarks/models/__init__.py | 4 ++++ benchmarks/models/transformer_lm.py | 2 +- benchmarks/moe.py | 5 +++++ benchmarks/oss.py | 2 +- benchmarks/pipe.py | 2 +- benchmarks/utils.py | 2 +- codecov.yml | 5 +++++ docs/Makefile | 5 +++++ docs/source/conf.py | 5 +++++ pyproject.toml | 2 +- requirements-dev.txt | 7 +++++-- 24 files changed, 63 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 389dc735c..45d178d5c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,8 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. + # If you change the versions below, please make sure they are in-sync # with requirements-dev.txt @@ -45,4 +50,5 @@ repos: hooks: - id: mypy args: [--no-strict-optional, --ignore-missing-imports, --scripts-are-modules, --pretty] - additional_dependencies: [numpy] + # See requirements-dev.txt for the reason for a fixed version of numpy here. + additional_dependencies: [numpy==1.21.5] diff --git a/CHANGELOG.md b/CHANGELOG.md index d56a07e88..a116cb865 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.4.6] - TBD + ### Added - CosFace's LMCL is added to MEVO. This is a loss function that is suitable for large number of prediction target classes. It added normalization, diff --git a/benchmarks/__init__.py b/benchmarks/__init__.py index e69de29bb..6677db08c 100644 --- a/benchmarks/__init__.py +++ b/benchmarks/__init__.py @@ -0,0 +1,4 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. diff --git a/benchmarks/datasets/__init__.py b/benchmarks/datasets/__init__.py index e69de29bb..6677db08c 100644 --- a/benchmarks/datasets/__init__.py +++ b/benchmarks/datasets/__init__.py @@ -0,0 +1,4 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. diff --git a/benchmarks/datasets/mnist.py b/benchmarks/datasets/mnist.py index a662c3ce8..ec8b1e6d9 100644 --- a/benchmarks/datasets/mnist.py +++ b/benchmarks/datasets/mnist.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/datasets/wikitext2_data.py b/benchmarks/datasets/wikitext2_data.py index ab5a004d6..62e1bdf0e 100644 --- a/benchmarks/datasets/wikitext2_data.py +++ b/benchmarks/datasets/wikitext2_data.py @@ -1,14 +1,14 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. from collections import namedtuple -from distutils.version import LooseVersion import io import operator import tempfile +from distutils.version import LooseVersion import torch from torch.utils.data import DataLoader from torch.utils.data.distributed import DistributedSampler diff --git a/benchmarks/experimental/benchmark_dataset.py b/benchmarks/experimental/benchmark_dataset.py index 83a14ac99..f4eda96fc 100644 --- a/benchmarks/experimental/benchmark_dataset.py +++ b/benchmarks/experimental/benchmark_dataset.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/experimental/benchmark_mevo.py b/benchmarks/experimental/benchmark_mevo.py index b5c1f6ac0..620ff8cc7 100644 --- a/benchmarks/experimental/benchmark_mevo.py +++ b/benchmarks/experimental/benchmark_mevo.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/experimental/sync_batchnorm.py b/benchmarks/experimental/sync_batchnorm.py index 7ba44db52..fa8a243f0 100644 --- a/benchmarks/experimental/sync_batchnorm.py +++ b/benchmarks/experimental/sync_batchnorm.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/fsdp.py b/benchmarks/fsdp.py index 75928717e..af3861390 100644 --- a/benchmarks/fsdp.py +++ b/benchmarks/fsdp.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/golden_configs/__init__.py b/benchmarks/golden_configs/__init__.py index e69de29bb..6677db08c 100644 --- a/benchmarks/golden_configs/__init__.py +++ b/benchmarks/golden_configs/__init__.py @@ -0,0 +1,4 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. diff --git a/benchmarks/golden_configs/lm_wikitext2.py b/benchmarks/golden_configs/lm_wikitext2.py index 633168abf..e7bce7406 100644 --- a/benchmarks/golden_configs/lm_wikitext2.py +++ b/benchmarks/golden_configs/lm_wikitext2.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/golden_configs/oss_mnist.py b/benchmarks/golden_configs/oss_mnist.py index b78b554b0..5b8658761 100644 --- a/benchmarks/golden_configs/oss_mnist.py +++ b/benchmarks/golden_configs/oss_mnist.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/models/__init__.py b/benchmarks/models/__init__.py index e69de29bb..6677db08c 100644 --- a/benchmarks/models/__init__.py +++ b/benchmarks/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. diff --git a/benchmarks/models/transformer_lm.py b/benchmarks/models/transformer_lm.py index 4deca44ca..b503745a3 100644 --- a/benchmarks/models/transformer_lm.py +++ b/benchmarks/models/transformer_lm.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/moe.py b/benchmarks/moe.py index 90cce132b..e6aaa506d 100644 --- a/benchmarks/moe.py +++ b/benchmarks/moe.py @@ -1,3 +1,8 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. + import logging import math import time diff --git a/benchmarks/oss.py b/benchmarks/oss.py index 23b1e4501..bd366d012 100755 --- a/benchmarks/oss.py +++ b/benchmarks/oss.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/pipe.py b/benchmarks/pipe.py index 724d89bf1..d1291e439 100644 --- a/benchmarks/pipe.py +++ b/benchmarks/pipe.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/benchmarks/utils.py b/benchmarks/utils.py index 4301a346f..1dcbdc880 100644 --- a/benchmarks/utils.py +++ b/benchmarks/utils.py @@ -1,4 +1,4 @@ -# Copyright (c) Facebook, Inc. and its affiliates. +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # # This source code is licensed under the BSD license found in the # LICENSE file in the root directory of this source tree. diff --git a/codecov.yml b/codecov.yml index f5567edc5..6eabaf549 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,3 +1,8 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. + codecov: require_ci_to_pass: yes coverage: diff --git a/docs/Makefile b/docs/Makefile index 008578dde..35e624c18 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,3 +1,8 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. + # Minimal makefile for Sphinx documentation # diff --git a/docs/source/conf.py b/docs/source/conf.py index 0f8cb8ce4..34a46b03a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,3 +1,8 @@ +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +# +# This source code is licensed under the BSD license found in the +# LICENSE file in the root directory of this source tree. + # type: ignore # Configuration file for the Sphinx documentation builder. # diff --git a/pyproject.toml b/pyproject.toml index cd9cd563b..dba7d9924 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,4 +27,4 @@ use_parentheses = true skip_glob = ["build/*", "stubs/*"] # Don't split "import" and "from". force_sort_within_sections = true -known_third_party = ["benchmark_dataset", "datasets", "golden_configs", "models", "numpy", "parameterized", "pytest", "recommonmark", "setuptools", "sklearn", "torch", "torchtext", "torchvision", "utils"] +known_third_party = ["benchmark_dataset", "datasets", "distutils", "golden_configs", "models", "numpy", "parameterized", "pytest", "recommonmark", "setuptools", "sklearn", "torch", "torchtext", "torchvision", "utils"] diff --git a/requirements-dev.txt b/requirements-dev.txt index fa77ae4e8..18269e6f3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,6 +10,7 @@ black == 21.10b0 flake8 == 4.0.1 flake8-annotations == 2.7.0 isort == 5.10.1 +seed-isort-config == 2.2.0 mypy == 0.910 pre-commit >= 2.15.0 @@ -26,8 +27,10 @@ docutils == 0.17 # For torch.cuda.list_gpu_processes() pynvml == 8.0.4 -# For mypy typing -numpy >= 1.21 +# For mypy typing. It is important to have a fixed version. Otherwise, you +# may run into mypy errors out differently for different versions. +# Using 1.21.5 for now because py3.7 only has up to 1.21.5, not 1.22.x. +numpy == 1.21.5 # For layerwise gradient scaler sklearn >= 0.0