Skip to content

Commit

Permalink
[chore] Fix copyright headers & fixed issue with mypy & NumPy version…
Browse files Browse the repository at this point in the history
…s 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 <min.xu.public@gmail.com>
  • Loading branch information
min-xu-ai and flying-x committed Mar 8, 2022
1 parent 2877474 commit 8fa26ae
Show file tree
Hide file tree
Showing 24 changed files with 63 additions and 17 deletions.
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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]
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions benchmarks/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion benchmarks/datasets/mnist.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/datasets/wikitext2_data.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/experimental/benchmark_dataset.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/experimental/benchmark_mevo.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/experimental/sync_batchnorm.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/fsdp.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/golden_configs/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion benchmarks/golden_configs/lm_wikitext2.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/golden_configs/oss_mnist.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion benchmarks/models/transformer_lm.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/moe.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/oss.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/pipe.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/utils.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 5 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
5 changes: 5 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -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
#

Expand Down
5 changes: 5 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
7 changes: 5 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit 8fa26ae

Please sign in to comment.