From cb28e0f291ad4e6ed678b10ebcb46243242f8820 Mon Sep 17 00:00:00 2001 From: Emma Smith Date: Thu, 18 Feb 2021 10:56:18 +0000 Subject: [PATCH] Update LICENSE (#111) --- .github/ISSUE_TEMPLATE/bug_report.md | 34 +++ .github/ISSUE_TEMPLATE/feature_request.md | 23 ++ .github/workflows/python-app.yml | 2 + LICENSE | 202 +++++++++++++++++- colearn/__init__.py | 17 ++ colearn/ml_interface.py | 17 ++ colearn/standalone_driver.py | 17 ++ colearn/training.py | 17 ++ colearn/utils/__init__.py | 17 ++ colearn/utils/data.py | 17 ++ colearn/utils/plot.py | 17 ++ colearn/utils/results.py | 17 ++ colearn_grpc/__init__.py | 17 ++ colearn_grpc/example_mli_factory.py | 17 ++ colearn_grpc/grpc_learner_server.py | 17 ++ colearn_grpc/grpc_server.py | 17 ++ colearn_grpc/logging.py | 17 ++ colearn_grpc/mli_factory_interface.py | 17 ++ colearn_grpc/proto/generated/interface_pb2.py | 17 ++ .../proto/generated/interface_pb2_grpc.py | 17 ++ colearn_grpc/test_example_mli_factory.py | 17 ++ colearn_keras/__init__.py | 17 ++ colearn_keras/keras_cifar10.py | 17 ++ colearn_keras/keras_learner.py | 17 ++ colearn_keras/keras_mnist.py | 17 ++ colearn_keras/test_keras_learner.py | 17 ++ colearn_keras/utils.py | 17 ++ colearn_other/__init__.py | 17 ++ colearn_other/fraud_dataset.py | 17 ++ colearn_other/mli_factory.py | 17 ++ colearn_pytorch/__init__.py | 17 ++ colearn_pytorch/pytorch_covid_xray.py | 17 ++ colearn_pytorch/pytorch_learner.py | 17 ++ colearn_pytorch/pytorch_xray.py | 17 ++ colearn_pytorch/test_pytorch_learner.py | 17 ++ colearn_pytorch/utils.py | 17 ++ docker/build.py | 17 ++ docs/python_src/mnist_keras.py | 17 ++ docs/python_src/mnist_pytorch.py | 17 ++ examples/keras_cifar.py | 17 ++ examples/keras_fraud.py | 17 ++ examples/keras_mnist.py | 17 ++ examples/keras_mnist_diffpriv.py | 17 ++ examples/keras_xray.py | 17 ++ examples/mli_fraud.py | 17 ++ examples/mli_random_forest_iris.py | 17 ++ examples/pytorch_cifar.py | 17 ++ examples/pytorch_covid.py | 17 ++ examples/pytorch_mnist.py | 17 ++ examples/pytorch_mnist_diffpriv.py | 17 ++ examples/pytorch_xray.py | 17 ++ examples/run_demo.py | 19 +- grpc_examples/run_grpc_server.py | 17 ++ setup.py | 17 ++ tests/__init__.py | 17 ++ tests/check_copyright_notice.py | 112 ++++++++++ tests/plus_one_learner/plus_one_learner.py | 17 ++ tests/plus_one_learner/plus_one_runner.py | 17 ++ .../plus_one_learner/test_plus_one_learner.py | 17 ++ tests/test_colearn_utils_data.py | 17 ++ tests/test_examples.py | 17 ++ tox.ini | 8 +- 62 files changed, 1332 insertions(+), 3 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100755 tests/check_copyright_notice.py diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..d054a08d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,34 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +Thanks for taking the time to let us know about a bug! +Please try to fill in as much as possible of this form so that we can fix it. + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..e55e459d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +Thanks for taking the time to let us know about a feature that you would like! +Please try to fill in as much as possible of this form so that we can help. + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index fb8db3f2..8da131b1 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -35,4 +35,6 @@ jobs: run: tox -e pytest - name: Build docs run: tox -e docs + - name: Check copyright notice + run: tox -e copyright_check diff --git a/LICENSE b/LICENSE index e0321de2..d3d77742 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1,201 @@ -NOT YET DEFINED + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2021 Fetch.AI Limited + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/colearn/__init__.py b/colearn/__init__.py index e69de29b..ca49ea0d 100644 --- a/colearn/__init__.py +++ b/colearn/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ diff --git a/colearn/ml_interface.py b/colearn/ml_interface.py index 3bc1b150..ea63e0e9 100644 --- a/colearn/ml_interface.py +++ b/colearn/ml_interface.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import abc from typing import Optional, Any, Dict from pydantic import BaseModel diff --git a/colearn/standalone_driver.py b/colearn/standalone_driver.py index 8b81b4bd..e93135c1 100644 --- a/colearn/standalone_driver.py +++ b/colearn/standalone_driver.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from typing import List, Sequence from colearn.ml_interface import MachineLearningInterface diff --git a/colearn/training.py b/colearn/training.py index 19e043c2..a133cabf 100644 --- a/colearn/training.py +++ b/colearn/training.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from typing import Sequence from colearn.ml_interface import ProposedWeights, MachineLearningInterface diff --git a/colearn/utils/__init__.py b/colearn/utils/__init__.py index e69de29b..ca49ea0d 100644 --- a/colearn/utils/__init__.py +++ b/colearn/utils/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ diff --git a/colearn/utils/data.py b/colearn/utils/data.py index 7e8f7f44..98a20cfa 100644 --- a/colearn/utils/data.py +++ b/colearn/utils/data.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os from pathlib import Path from typing import List, Union diff --git a/colearn/utils/plot.py b/colearn/utils/plot.py index c32d0db5..1e63c23f 100644 --- a/colearn/utils/plot.py +++ b/colearn/utils/plot.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import matplotlib.axes._axes as mpl_ax import matplotlib.patches as mpatches import matplotlib.pyplot as plt diff --git a/colearn/utils/results.py b/colearn/utils/results.py index b1d84ab3..9f03418b 100644 --- a/colearn/utils/results.py +++ b/colearn/utils/results.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from typing import List import numpy as np diff --git a/colearn_grpc/__init__.py b/colearn_grpc/__init__.py index e69de29b..ca49ea0d 100644 --- a/colearn_grpc/__init__.py +++ b/colearn_grpc/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ diff --git a/colearn_grpc/example_mli_factory.py b/colearn_grpc/example_mli_factory.py index 41d4a765..38048d4e 100644 --- a/colearn_grpc/example_mli_factory.py +++ b/colearn_grpc/example_mli_factory.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import json from inspect import signature from typing import Set, Dict, Any diff --git a/colearn_grpc/grpc_learner_server.py b/colearn_grpc/grpc_learner_server.py index 60111ec3..29a6c518 100644 --- a/colearn_grpc/grpc_learner_server.py +++ b/colearn_grpc/grpc_learner_server.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import json import pickle from threading import Lock diff --git a/colearn_grpc/grpc_server.py b/colearn_grpc/grpc_server.py index 089b8963..642f2633 100644 --- a/colearn_grpc/grpc_server.py +++ b/colearn_grpc/grpc_server.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from concurrent import futures import grpc diff --git a/colearn_grpc/logging.py b/colearn_grpc/logging.py index a451718b..fcd98050 100644 --- a/colearn_grpc/logging.py +++ b/colearn_grpc/logging.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import logging import sys import click diff --git a/colearn_grpc/mli_factory_interface.py b/colearn_grpc/mli_factory_interface.py index 4fbeb599..1b2a0161 100644 --- a/colearn_grpc/mli_factory_interface.py +++ b/colearn_grpc/mli_factory_interface.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import abc from typing import Dict, Set, Any diff --git a/colearn_grpc/proto/generated/interface_pb2.py b/colearn_grpc/proto/generated/interface_pb2.py index 60e6696f..0f71b1da 100644 --- a/colearn_grpc/proto/generated/interface_pb2.py +++ b/colearn_grpc/proto/generated/interface_pb2.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: interface.proto diff --git a/colearn_grpc/proto/generated/interface_pb2_grpc.py b/colearn_grpc/proto/generated/interface_pb2_grpc.py index b2048cd7..2776270e 100644 --- a/colearn_grpc/proto/generated/interface_pb2_grpc.py +++ b/colearn_grpc/proto/generated/interface_pb2_grpc.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! """Client and server classes corresponding to protobuf-defined services.""" import grpc diff --git a/colearn_grpc/test_example_mli_factory.py b/colearn_grpc/test_example_mli_factory.py index 6e4ac92a..b0f56658 100644 --- a/colearn_grpc/test_example_mli_factory.py +++ b/colearn_grpc/test_example_mli_factory.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import json import pytest diff --git a/colearn_keras/__init__.py b/colearn_keras/__init__.py index e69de29b..ca49ea0d 100644 --- a/colearn_keras/__init__.py +++ b/colearn_keras/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ diff --git a/colearn_keras/keras_cifar10.py b/colearn_keras/keras_cifar10.py index 63906d22..24e4610a 100644 --- a/colearn_keras/keras_cifar10.py +++ b/colearn_keras/keras_cifar10.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import pickle import tempfile diff --git a/colearn_keras/keras_learner.py b/colearn_keras/keras_learner.py index e5a5e003..e6781d90 100644 --- a/colearn_keras/keras_learner.py +++ b/colearn_keras/keras_learner.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from inspect import signature from typing import Optional diff --git a/colearn_keras/keras_mnist.py b/colearn_keras/keras_mnist.py index da455ce0..12f95421 100644 --- a/colearn_keras/keras_mnist.py +++ b/colearn_keras/keras_mnist.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import pickle import tempfile diff --git a/colearn_keras/test_keras_learner.py b/colearn_keras/test_keras_learner.py index b77504dd..4f80b193 100644 --- a/colearn_keras/test_keras_learner.py +++ b/colearn_keras/test_keras_learner.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from unittest import mock import pytest diff --git a/colearn_keras/utils.py b/colearn_keras/utils.py index c5d7cf7d..fcdc03d9 100644 --- a/colearn_keras/utils.py +++ b/colearn_keras/utils.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import tensorflow as tf diff --git a/colearn_other/__init__.py b/colearn_other/__init__.py index e69de29b..ca49ea0d 100644 --- a/colearn_other/__init__.py +++ b/colearn_other/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ diff --git a/colearn_other/fraud_dataset.py b/colearn_other/fraud_dataset.py index 97fc0cfb..8a93f524 100644 --- a/colearn_other/fraud_dataset.py +++ b/colearn_other/fraud_dataset.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import pickle import tempfile diff --git a/colearn_other/mli_factory.py b/colearn_other/mli_factory.py index 82e4ff3c..730fb451 100644 --- a/colearn_other/mli_factory.py +++ b/colearn_other/mli_factory.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from enum import Enum from typing import Optional from colearn.ml_interface import MachineLearningInterface diff --git a/colearn_pytorch/__init__.py b/colearn_pytorch/__init__.py index e69de29b..ca49ea0d 100644 --- a/colearn_pytorch/__init__.py +++ b/colearn_pytorch/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ diff --git a/colearn_pytorch/pytorch_covid_xray.py b/colearn_pytorch/pytorch_covid_xray.py index 1b2416d9..1af520fe 100644 --- a/colearn_pytorch/pytorch_covid_xray.py +++ b/colearn_pytorch/pytorch_covid_xray.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import pickle import tempfile diff --git a/colearn_pytorch/pytorch_learner.py b/colearn_pytorch/pytorch_learner.py index 374d3554..530e8d7c 100644 --- a/colearn_pytorch/pytorch_learner.py +++ b/colearn_pytorch/pytorch_learner.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from typing import Optional, Callable try: diff --git a/colearn_pytorch/pytorch_xray.py b/colearn_pytorch/pytorch_xray.py index 49b03076..31e7db4b 100644 --- a/colearn_pytorch/pytorch_xray.py +++ b/colearn_pytorch/pytorch_xray.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import random as rand import tempfile diff --git a/colearn_pytorch/test_pytorch_learner.py b/colearn_pytorch/test_pytorch_learner.py index 26c48fec..6eb02c9c 100644 --- a/colearn_pytorch/test_pytorch_learner.py +++ b/colearn_pytorch/test_pytorch_learner.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from unittest.mock import Mock, create_autospec import pytest diff --git a/colearn_pytorch/utils.py b/colearn_pytorch/utils.py index 91f75bf4..fd3365f9 100644 --- a/colearn_pytorch/utils.py +++ b/colearn_pytorch/utils.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from typing import List import torch diff --git a/docker/build.py b/docker/build.py index bb75b61c..4579d9ec 100644 --- a/docker/build.py +++ b/docker/build.py @@ -1,4 +1,21 @@ #!/usr/bin/env python3 +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import subprocess import argparse diff --git a/docs/python_src/mnist_keras.py b/docs/python_src/mnist_keras.py index 6807ae29..b24bdea8 100644 --- a/docs/python_src/mnist_keras.py +++ b/docs/python_src/mnist_keras.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import tensorflow as tf import tensorflow_datasets as tfds diff --git a/docs/python_src/mnist_pytorch.py b/docs/python_src/mnist_pytorch.py index 28277dcb..05a90743 100644 --- a/docs/python_src/mnist_pytorch.py +++ b/docs/python_src/mnist_pytorch.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from torchsummary import summary from torchvision import transforms, datasets import torch.utils.data diff --git a/examples/keras_cifar.py b/examples/keras_cifar.py index a349ba8b..d9c26c84 100644 --- a/examples/keras_cifar.py +++ b/examples/keras_cifar.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import tensorflow as tf diff --git a/examples/keras_fraud.py b/examples/keras_fraud.py index 4c716fa7..f1ff1862 100644 --- a/examples/keras_fraud.py +++ b/examples/keras_fraud.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import argparse import os from pathlib import Path diff --git a/examples/keras_mnist.py b/examples/keras_mnist.py index 350f0f3a..fecacb63 100644 --- a/examples/keras_mnist.py +++ b/examples/keras_mnist.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import tensorflow as tf diff --git a/examples/keras_mnist_diffpriv.py b/examples/keras_mnist_diffpriv.py index a434777d..d246b11e 100644 --- a/examples/keras_mnist_diffpriv.py +++ b/examples/keras_mnist_diffpriv.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import tensorflow as tf diff --git a/examples/keras_xray.py b/examples/keras_xray.py index 71d76ec3..ef0e3c3c 100644 --- a/examples/keras_xray.py +++ b/examples/keras_xray.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import argparse import os import sys diff --git a/examples/mli_fraud.py b/examples/mli_fraud.py index ecc2cd28..6d68d97d 100644 --- a/examples/mli_fraud.py +++ b/examples/mli_fraud.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import argparse import os from pathlib import Path diff --git a/examples/mli_random_forest_iris.py b/examples/mli_random_forest_iris.py index ab9607df..6f5ed79f 100644 --- a/examples/mli_random_forest_iris.py +++ b/examples/mli_random_forest_iris.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import numpy as np diff --git a/examples/pytorch_cifar.py b/examples/pytorch_cifar.py index 8612b013..5eebb96d 100644 --- a/examples/pytorch_cifar.py +++ b/examples/pytorch_cifar.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os from typing_extensions import TypedDict diff --git a/examples/pytorch_covid.py b/examples/pytorch_covid.py index fc0ea99b..a42b306e 100644 --- a/examples/pytorch_covid.py +++ b/examples/pytorch_covid.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import argparse import os import sys diff --git a/examples/pytorch_mnist.py b/examples/pytorch_mnist.py index b4c2246d..fc2a8bfe 100644 --- a/examples/pytorch_mnist.py +++ b/examples/pytorch_mnist.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os from typing_extensions import TypedDict diff --git a/examples/pytorch_mnist_diffpriv.py b/examples/pytorch_mnist_diffpriv.py index c746c9a3..9df0f320 100644 --- a/examples/pytorch_mnist_diffpriv.py +++ b/examples/pytorch_mnist_diffpriv.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os from typing_extensions import TypedDict diff --git a/examples/pytorch_xray.py b/examples/pytorch_xray.py index 960be9a3..63a8ce33 100644 --- a/examples/pytorch_xray.py +++ b/examples/pytorch_xray.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import argparse import os import random as rand diff --git a/examples/run_demo.py b/examples/run_demo.py index ad6ff0aa..79cb356e 100755 --- a/examples/run_demo.py +++ b/examples/run_demo.py @@ -1,4 +1,21 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import argparse import os from typing import Optional, Sequence diff --git a/grpc_examples/run_grpc_server.py b/grpc_examples/run_grpc_server.py index beecde67..1e937460 100644 --- a/grpc_examples/run_grpc_server.py +++ b/grpc_examples/run_grpc_server.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import argparse import signal import sys diff --git a/setup.py b/setup.py index f5da0c30..cf5992cc 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import setuptools keras_deps = [ diff --git a/tests/__init__.py b/tests/__init__.py index e69de29b..ca49ea0d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ diff --git a/tests/check_copyright_notice.py b/tests/check_copyright_notice.py new file mode 100755 index 00000000..1b7e9dd8 --- /dev/null +++ b/tests/check_copyright_notice.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +""" +This script checks that all the Python files of the repository have: + +- (optional) the Python shebang +- the encoding header; +- the copyright notice; + +It is assumed the script is run from the repository root. +""" + +import itertools +import re +import sys +from pathlib import Path + + +HEADER_REGEX = r"""(#!/usr/bin/env python3 +)?# ------------------------------------------------------------------------------ +# +# (Copyright 2021 Fetch.AI Limited|Copyright [0-9]{4}(-[0-9]{4})? [a-zA-Z_]+) +# +# Licensed under the Apache License, Version 2\.0 \(the \"License\"\); +# you may not use this file except in compliance with the License\. +# You may obtain a copy of the License at +# +# http://www\.apache\.org/licenses/LICENSE-2\.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an \"AS IS\" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\. +# See the License for the specific language governing permissions and +# limitations under the License\. +# +# ------------------------------------------------------------------------------ +""" + + +def check_copyright(file: Path) -> bool: + """ + Given a file, check if the header stuff is in place. + + Return True if the files has the encoding header and the copyright notice, + optionally prefixed by the shebang. Return False otherwise. + + :param file: the file to check. + :return True if the file is compliant with the checks, False otherwise. + """ + content = file.read_text() + header_regex = re.compile(HEADER_REGEX, re.MULTILINE) + return re.match(header_regex, content) is not None + + +def parse_args(): + """Parse arguments.""" + import argparse # pylint: disable=import-outside-toplevel + + parser = argparse.ArgumentParser("check_copyright_notice") + parser.add_argument( + "--directory", type=str, default=".", help="The path to the repository root." + ) + + +if __name__ == "__main__": + python_files = itertools.chain( + Path("colearn").glob("**/*.py"), + Path("colearn_grpc").glob("**/*.py"), + Path("colearn_keras").glob("**/*.py"), + Path("colearn_other").glob("**/*.py"), + Path("colearn_pytorch").glob("**/*.py"), + Path("docker").glob("**/*.py"), + Path("docs").glob("**/*.py"), + Path("examples").glob("**/*.py"), + Path("grpc_examples").glob("**/*.py"), + Path("tests").glob("**/*.py"), + [Path("setup.py")], + ) + + # filter out protobuf files (*_pb2.py) + python_files_filtered = filter( + lambda x: not str(x).endswith("_pb2.py"), python_files + ) + + bad_files = [ + filepath for filepath in python_files_filtered if not check_copyright(filepath) + ] + + if len(bad_files) > 0: + print("The following files are not well formatted:") + print("\n".join(map(str, bad_files))) + sys.exit(1) + else: + print("OK") + sys.exit(0) diff --git a/tests/plus_one_learner/plus_one_learner.py b/tests/plus_one_learner/plus_one_learner.py index e277ef18..46c0ad8d 100644 --- a/tests/plus_one_learner/plus_one_learner.py +++ b/tests/plus_one_learner/plus_one_learner.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from colearn.ml_interface import MachineLearningInterface, ProposedWeights, \ Weights diff --git a/tests/plus_one_learner/plus_one_runner.py b/tests/plus_one_learner/plus_one_runner.py index 8b109df9..5e5e2da0 100644 --- a/tests/plus_one_learner/plus_one_runner.py +++ b/tests/plus_one_learner/plus_one_runner.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from colearn.standalone_driver import run from tests.plus_one_learner.plus_one_learner import PlusOneLearner diff --git a/tests/plus_one_learner/test_plus_one_learner.py b/tests/plus_one_learner/test_plus_one_learner.py index 4b1055a0..fb889038 100644 --- a/tests/plus_one_learner/test_plus_one_learner.py +++ b/tests/plus_one_learner/test_plus_one_learner.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ from tests.plus_one_learner.plus_one_learner import PlusOneLearner diff --git a/tests/test_colearn_utils_data.py b/tests/test_colearn_utils_data.py index 2f193a22..3436f264 100644 --- a/tests/test_colearn_utils_data.py +++ b/tests/test_colearn_utils_data.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import numpy as np import pytest diff --git a/tests/test_examples.py b/tests/test_examples.py index 33c78147..1d99685c 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -1,3 +1,20 @@ +# ------------------------------------------------------------------------------ +# +# Copyright 2021 Fetch.AI Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ import os import subprocess from pathlib import Path diff --git a/tox.ini b/tox.ini index 922c8bd9..50590dce 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ ; the package installation). [tox] -envlist = flake8, mypy, pylint, pytest, docs +envlist = flake8, mypy, pylint, pytest, docs, copyright_check [testenv] basepython = python3.7 @@ -73,6 +73,12 @@ deps = markdown==3.2.1 mkdocs-material-extensions==1.0.1 commands = mkdocs build --clean +[testenv:copyright_check] +skipsdist = True +skip_install = True +deps = +commands = {toxinidir}/tests/check_copyright_notice.py --directory {toxinidir} + [pytest] markers = slow: mark test as slow \ No newline at end of file