From 08fc1d277fdd5954cf59a254c23c1bdaa78a27bc Mon Sep 17 00:00:00 2001 From: Cecilia Nievas Date: Fri, 22 Apr 2022 09:32:36 +0200 Subject: [PATCH] Added basic initial project structure and CI pipeline --- .gitlab-ci.yml | 27 +++++++++++++++++++++++++ Makefile | 10 ++++++++++ gdeexporter/__init__.py | 17 ++++++++++++++++ gdeexporter/gdeexporter.py | 40 ++++++++++++++++++++++++++++++++++++++ setup.py | 39 +++++++++++++++++++++++++++++++++++++ tests/__init__.py | 17 ++++++++++++++++ tests/test_gdeexporter.py | 25 ++++++++++++++++++++++++ 7 files changed, 175 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 Makefile create mode 100644 gdeexporter/__init__.py create mode 100644 gdeexporter/gdeexporter.py create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/test_gdeexporter.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..75b7fee --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,27 @@ +image: python:3.9-bullseye + +# Make pip cache the installed dependencies +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + +cache: + paths: + - .cache/pip + - venv/ + +before_script: + - python3 -V + - pip3 install virtualenv + - virtualenv venv + - source venv/bin/activate + - pip3 install . + - pip3 install .[tests] + +linters: + script: + - pip3 install .[linters] + - make check + +tests: + script: + - pytest tests diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a1b2560 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +SOURCES=gdeexporter tests setup.py +LENGTH=96 + +check: $(SOURCES) + flake8 --max-line-length=$(LENGTH) --ignore=E203,W503 $^ + black --check --line-length $(LENGTH) $^ + pylint -E $^ + +format: $(SOURCES) + black --line-length $(LENGTH) $^ diff --git a/gdeexporter/__init__.py b/gdeexporter/__init__.py new file mode 100644 index 0000000..4875bf7 --- /dev/null +++ b/gdeexporter/__init__.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2022: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. diff --git a/gdeexporter/gdeexporter.py b/gdeexporter/gdeexporter.py new file mode 100644 index 0000000..222e43a --- /dev/null +++ b/gdeexporter/gdeexporter.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2022: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +import logging +import sys + +# Add a logger printing error, warning, info and debug messages to the screen +logger = logging.getLogger() +logger.setLevel(logging.INFO) +logger.addHandler(logging.StreamHandler(sys.stdout)) + + +def main(): + """Run the gde-exporter.""" + + # Log the start of the run + logger.info("gde-exporter has started") + + # Leave the program + logger.info("gde-exporter has finished") + sys.exit() + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e8046db --- /dev/null +++ b/setup.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2022: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +from setuptools import setup, find_packages + +tests_require = ["pytest"] +linters_require = ["black>=22.1.0", "pylint", "flake8"] + +setup( + name="gdeexporter", + version="0.0.1", + description="Exporter of the GDE model", + keywords="Global Dynamic Exposure, GDE, buildings, exposure model", + author="Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ", + license="AGPLv3+", + install_requires=["numpy"], + extras_require={ + "tests": tests_require, + "linters": linters_require, + }, + packages=find_packages(), + entry_points={"console_scripts": ["gdeexporter = gdeexporter.gdeexporter:main"]}, + python_requires=">=3.7, <3.10", +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..4875bf7 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2022: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. diff --git a/tests/test_gdeexporter.py b/tests/test_gdeexporter.py new file mode 100644 index 0000000..05a70f7 --- /dev/null +++ b/tests/test_gdeexporter.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2022: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +import logging + +logger = logging.getLogger() + + +def test_main(): + pass -- GitLab