From 23407ef0be56fbab120019c7b786eb164e255d44 Mon Sep 17 00:00:00 2001 From: Wessel Bruinsma Date: Tue, 30 Jul 2024 15:09:46 +0200 Subject: [PATCH] Refactor copyright notice --- aurora/__init__.py | 4 +--- aurora/area.py | 4 +--- aurora/batch.py | 4 +--- aurora/model/__init__.py | 4 +--- aurora/model/aurora.py | 4 +--- aurora/model/film.py | 4 +--- aurora/model/fourier.py | 4 +--- aurora/model/groupedpatchembed.py | 4 +--- aurora/model/helpers.py | 4 +--- aurora/model/lora.py | 4 +--- aurora/model/perceiver.py | 10 +++++----- aurora/model/perceiver_decoder.py | 4 +--- aurora/model/perceiver_encoder.py | 4 +--- aurora/model/pos_encode.py | 3 +-- aurora/model/swin_3d_block.py | 11 ++++++----- aurora/model/swin_block.py | 11 ++--------- aurora/model/vit_block.py | 3 +-- tests/test_core.py | 7 ------- tests/test_headers.py | 13 +++---------- tests/test_model.py | 1 + 20 files changed, 31 insertions(+), 76 deletions(-) delete mode 100644 tests/test_core.py create mode 100644 tests/test_model.py diff --git a/aurora/__init__.py b/aurora/__init__.py index 76d2201..410d493 100644 --- a/aurora/__init__.py +++ b/aurora/__init__.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" from aurora.model.aurora import Aurora, AuroraSmall diff --git a/aurora/area.py b/aurora/area.py index 5e4859e..3abeef7 100644 --- a/aurora/area.py +++ b/aurora/area.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" import torch diff --git a/aurora/batch.py b/aurora/batch.py index 51939dc..dde7b9d 100644 --- a/aurora/batch.py +++ b/aurora/batch.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" import dataclasses from datetime import datetime diff --git a/aurora/model/__init__.py b/aurora/model/__init__.py index 8bfada9..a679a52 100644 --- a/aurora/model/__init__.py +++ b/aurora/model/__init__.py @@ -1,3 +1 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" diff --git a/aurora/model/aurora.py b/aurora/model/aurora.py index 5d77e47..aae4f89 100644 --- a/aurora/model/aurora.py +++ b/aurora/model/aurora.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" from datetime import timedelta from functools import partial diff --git a/aurora/model/film.py b/aurora/model/film.py index 12554f1..76ada1c 100644 --- a/aurora/model/film.py +++ b/aurora/model/film.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" import torch from torch import nn diff --git a/aurora/model/fourier.py b/aurora/model/fourier.py index a667808..6319c53 100644 --- a/aurora/model/fourier.py +++ b/aurora/model/fourier.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" import math diff --git a/aurora/model/groupedpatchembed.py b/aurora/model/groupedpatchembed.py index 1c44cc0..d307af2 100644 --- a/aurora/model/groupedpatchembed.py +++ b/aurora/model/groupedpatchembed.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" import math from collections.abc import Iterable diff --git a/aurora/model/helpers.py b/aurora/model/helpers.py index 47502f9..02191fa 100644 --- a/aurora/model/helpers.py +++ b/aurora/model/helpers.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" from typing import TypeVar diff --git a/aurora/model/lora.py b/aurora/model/lora.py index 736f37c..4f50398 100644 --- a/aurora/model/lora.py +++ b/aurora/model/lora.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" import math from typing import Literal diff --git a/aurora/model/perceiver.py b/aurora/model/perceiver.py index 6a474b3..5fd95e2 100644 --- a/aurora/model/perceiver.py +++ b/aurora/model/perceiver.py @@ -1,11 +1,11 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license. Basic blocks for the Perceiver architecture. -The code borrows elements from the following repositories: -https://github.com/lucidrains/perceiver-pytorch/blob/main/perceiver_pytorch/perceiver_pytorch.py -https://github.com/mlfoundations/open_flamingo/blob/main/open_flamingo/src/helpers.py +The code borrows elements from the following files: + + https://github.com/lucidrains/perceiver-pytorch/blob/main/perceiver_pytorch/perceiver_pytorch.py + https://github.com/mlfoundations/open_flamingo/blob/main/open_flamingo/src/helpers.py """ import torch diff --git a/aurora/model/perceiver_decoder.py b/aurora/model/perceiver_decoder.py index 5f601e5..86ca11a 100644 --- a/aurora/model/perceiver_decoder.py +++ b/aurora/model/perceiver_decoder.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" from datetime import timedelta diff --git a/aurora/model/perceiver_encoder.py b/aurora/model/perceiver_encoder.py index 48bca37..3ee2393 100644 --- a/aurora/model/perceiver_encoder.py +++ b/aurora/model/perceiver_encoder.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" from datetime import timedelta diff --git a/aurora/model/pos_encode.py b/aurora/model/pos_encode.py index c6d0604..25c7174 100644 --- a/aurora/model/pos_encode.py +++ b/aurora/model/pos_encode.py @@ -1,5 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license. TODO(Johannes): not sure what to do with the licensing, now all used functions have been newly written by myself diff --git a/aurora/model/swin_3d_block.py b/aurora/model/swin_3d_block.py index f456712..82e9f2b 100644 --- a/aurora/model/swin_3d_block.py +++ b/aurora/model/swin_3d_block.py @@ -1,9 +1,10 @@ +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license. + +Code adapted from + + https://github.com/microsoft/Swin-Transformer/blob/main/models/swin_transformer_v2.py + """ -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" -# -------------------------------------------------------- -# Code adapted from https://github.com/microsoft/Swin-Transformer/blob/main/models/swin_transformer_v2.py -# -------------------------------------------------------- import itertools from functools import lru_cache diff --git a/aurora/model/swin_block.py b/aurora/model/swin_block.py index 5105ea9..cdd61cd 100644 --- a/aurora/model/swin_block.py +++ b/aurora/model/swin_block.py @@ -1,17 +1,10 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. - --------------------------------------------------------- -Swin Transformer V2 -Copyright (c) 2022 Microsoft -Licensed under The MIT License [see LICENSE for details] -Written by Ze Liu +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license. Code adapted from https://github.com/microsoft/Swin-Transformer/blob/main/models/swin_transformer_v2.py --------------------------------------------------------- +which was written by Ze Liu. """ from functools import lru_cache diff --git a/aurora/model/vit_block.py b/aurora/model/vit_block.py index 8869baa..58e40f7 100644 --- a/aurora/model/vit_block.py +++ b/aurora/model/vit_block.py @@ -1,5 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license. Extends TIMM transformer block with compute and memory efficient FlashAttention diff --git a/tests/test_core.py b/tests/test_core.py deleted file mode 100644 index 65a07f8..0000000 --- a/tests/test_core.py +++ /dev/null @@ -1,7 +0,0 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" - - -def test(): - assert 1 == 1 diff --git a/tests/test_headers.py b/tests/test_headers.py index ea79a43..cc31983 100644 --- a/tests/test_headers.py +++ b/tests/test_headers.py @@ -1,6 +1,4 @@ -""" -Copyright (c) Microsoft Corporation. Licensed under the MIT license. -""" +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.""" from pathlib import Path @@ -9,10 +7,7 @@ SKIP_FILES: set[str] = {"_version.py"} """set[str]: These files are not required to have a copyright notice.""" -COPYRIGHT_NOTICE: list[str] = [ - '"""', - "Copyright (c) Microsoft Corporation. Licensed under the MIT license.", -] +COPYRIGHT_NOTICE: str = '"""Copyright (c) Microsoft Corporation. Licensed under the MIT license.' @pytest.mark.parametrize("python_file", Path(__file__).parents[1].rglob("**/*.py")) @@ -23,7 +18,5 @@ def test_presence_of_copyright_header(python_file: Path) -> None: with open(python_file) as f: lines = list(f.read().splitlines()) - contains_notice = len(lines) >= len(COPYRIGHT_NOTICE) - contains_notice &= all(x.strip() == y.strip() for x, y in zip(lines, COPYRIGHT_NOTICE)) - if not contains_notice: + if not lines or not lines[0].startswith(COPYRIGHT_NOTICE): raise AssertionError(f"`{python_file}` must start with the copyright notice.") diff --git a/tests/test_model.py b/tests/test_model.py new file mode 100644 index 0000000..a679a52 --- /dev/null +++ b/tests/test_model.py @@ -0,0 +1 @@ +"""Copyright (c) Microsoft Corporation. Licensed under the MIT license."""