Unverified Commit f6ec5394 authored by Yuge Zhang's avatar Yuge Zhang Committed by GitHub
Browse files

Check copyright header (#4599)

parent cadf3a55
...@@ -342,3 +342,17 @@ For more information see the `Code of Conduct FAQ <https://opensource.microsoft. ...@@ -342,3 +342,17 @@ For more information see the `Code of Conduct FAQ <https://opensource.microsoft.
Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
We enforce every source files in this project to carry a license header. This should be added at the beginning of each file. Please contact the maintainer if you think there should be an exception.
.. tabs::
.. code-tab:: python
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
.. code-tab:: typescript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import absolute_import from __future__ import absolute_import
from .mutator import FBNetMutator # noqa: F401 from .mutator import FBNetMutator # noqa: F401
......
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .mutator import ProxylessNasMutator from .mutator import ProxylessNasMutator
from .trainer import ProxylessNasTrainer from .trainer import ProxylessNasTrainer
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .mutator import RandomMutator from .mutator import RandomMutator
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch import torch
import torch.nn.functional as F import torch.nn.functional as F
......
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .functional import FunctionalEvaluator from .functional import FunctionalEvaluator
...@@ -60,6 +60,8 @@ def generate_stub_file() -> str: ...@@ -60,6 +60,8 @@ def generate_stub_file() -> str:
] ]
code = [ code = [
'# Copyright (c) Microsoft Corporation.',
'# Licensed under the MIT license.',
'# This file is auto-generated to make auto-completion work.', '# This file is auto-generated to make auto-completion work.',
'# When pytorch version does not match, it will get automatically updated.', '# When pytorch version does not match, it will get automatically updated.',
'# pylint: skip-file', '# pylint: skip-file',
......
...@@ -3,6 +3,14 @@ trigger: none ...@@ -3,6 +3,14 @@ trigger: none
stages: stages:
- stage: lint - stage: lint
jobs: jobs:
- job: copyright
pool:
vmImage: ubuntu-latest
steps:
- script: python test/vso_tools/copyright_check.py
displayName: Check copyright header
- job: docs - job: docs
pool: pool:
vmImage: ubuntu-latest vmImage: ubuntu-latest
......
import os
import sys
invalid_files = []
copyright_headers = [
'# Copyright (c) Microsoft Corporation.\n# Licensed under the MIT license.',
'# Copyright (c) Microsoft Corporation. All rights reserved.\n#\n# MIT License',
]
whitelist = [
'nni/version.py',
'nni/algorithms/hpo/bohb_advisor/config_generator.py',
]
for root, dirs, files in os.walk('nni'):
for file in files:
if not file.endswith('.py'):
continue
full_path = os.path.join(root, file)
if full_path in whitelist:
continue
content = open(full_path).read()
if not content.strip():
# empty file
continue
if not any(content.startswith(header) for header in copyright_headers):
invalid_files.append(full_path)
if invalid_files:
print("The following files doesn't have a copyright text header.\n")
for file in invalid_files:
print(' ' + file)
print('\nPlease add the following text at the beginning of the file.\n')
print('# Copyright (c) Microsoft Corporation.\n# Licensed under the MIT license.')
sys.exit(1)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment