From 957581b1c00b63f757cafafa5c00740e36914b7e Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 17 Feb 2020 13:57:03 +0100 Subject: [PATCH 1/3] Create pyproject.toml and add initial Python package --- pyproject.toml | 57 +++++++++++++++++++++++++++++++++++++++ src/flower/__init__.py | 14 ++++++++++ src/flower/server.py | 29 ++++++++++++++++++++ src/flower/server_test.py | 28 +++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 pyproject.toml create mode 100644 src/flower/__init__.py create mode 100644 src/flower/server.py create mode 100644 src/flower/server_test.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000000..baf5585589ec --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,57 @@ +[build-system] +requires = [ + "poetry==1.0.3", +] +build-backend = "poetry.masonry.api" + +[tool.poetry] +name = "flower" +version = "0.0.1" +description = "See `README.md`" +license = "Apache License Version 2.0" +authors = [ + "Daniel J. Beutel ", + "Taner Topal ", +] +readme = "README.md" +homepage = "https://github.com/adap/flower" +repository = "https://github.com/adap/flower" +documentation = "https://github.com/adap/flower" +classifiers = [ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: Apache Software License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Typing :: Typed", +] +packages = [ + { include = "flower", from = "src" }, +] +exclude = [ + "src/**/*_test.py", +] + +[tool.poetry.dependencies] +python = "==3.7.6" +numpy = "==1.18.1" + +[tool.poetry.dev-dependencies] +isort = "==4.3.21" +black = "==19.10b0" +mypy = "==0.761" +pylint = "==2.4.4" +pytest = "==5.3.4" + +[tool.poetry.scripts] +server = "flower.server:main" + +[tool.isort] +line_length = 88 # Black defaults to 88 +indent = " " +multi_line_output = 3 + +[tool.black] +target-version = ['py37'] diff --git a/src/flower/__init__.py b/src/flower/__init__.py new file mode 100644 index 000000000000..a87c9e62f22a --- /dev/null +++ b/src/flower/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2020 Adap GmbH. All Rights Reserved. +# +# 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/src/flower/server.py b/src/flower/server.py new file mode 100644 index 000000000000..a782d9e74fc9 --- /dev/null +++ b/src/flower/server.py @@ -0,0 +1,29 @@ +# Copyright 2020 Adap GmbH. All Rights Reserved. +# +# 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. +# ============================================================================== +"""Flower server""" + + +def main(): + """Flower main function""" + print(message()) + + +def message() -> str: + """Initial message""" + return "server started" + + +if __name__ == "__main__": + main() diff --git a/src/flower/server_test.py b/src/flower/server_test.py new file mode 100644 index 000000000000..43cf72a1e1b3 --- /dev/null +++ b/src/flower/server_test.py @@ -0,0 +1,28 @@ +# Copyright 2020 Adap GmbH. All Rights Reserved. +# +# 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. +# ============================================================================== +"""Flower server tests""" + + +from .server import message + + +def test_message(): + """Test message function""" + # Prepare + expected = "server started" + # Execute + actual = message() + # Assert + assert actual == expected From c110b47fa775ece844d0f9edb66cb99c6a6bb79f Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 17 Feb 2020 14:13:41 +0100 Subject: [PATCH 2/3] Setup CI using GitHub Actions --- .github/workflows/py.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/py.yml diff --git a/.github/workflows/py.yml b/.github/workflows/py.yml new file mode 100644 index 000000000000..68ecec469286 --- /dev/null +++ b/.github/workflows/py.yml @@ -0,0 +1,29 @@ +name: Python CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.7.6 + - name: Install build tools + run: | + python -m pip install -U pip==20.0.2 + python -m pip install -U setuptools==45.1.0 + python -m pip install -U poetry==1.0.3 + poetry config virtualenvs.create false + - name: Install dependencies + run: python -m poetry install + - name: Lint + Test (isort/black/mypy/pylint/pytest) + run: ./dev/test.sh From 74f60a337daea6428c77c86729499532fc2ed55e Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 17 Feb 2020 14:29:09 +0100 Subject: [PATCH 3/3] Add README.md --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000000..cf5b7f5d8b64 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Flower