diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..4efbaff --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,89 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + + push: {} + + release: + types: [created] + +jobs: + quality: + name: Code QA + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: pip install black flake8 isort + - run: black --version + - run: isort --version + - run: flake8 --version + - run: isort --check . + - run: black --check . + - run: flake8 . + + checks: + if: ${{ github.event_name == 'release' }} + + strategy: + fail-fast: false + matrix: + platform: ["ubuntu-latest", "macos-latest"] + python-version: ["3.10"] + + name: Python ${{ matrix.python-version }} on ${{ matrix.platform }} + runs-on: ${{ matrix.platform }} + needs: quality + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install + run: | + pip install pytest + pip install -e . + pip install -r tests/requirements.txt + pip freeze + + - name: Tests + run: pytest + + deploy: + + if: ${{ github.event_name == 'release' }} + runs-on: ubuntu-latest + needs: checks + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Check that tag version matches code version + run: | + tag=${GITHUB_REF#refs/tags/} + version=$(python setup.py --version) + echo 'tag='$tag + echo "version file="$version + test "$tag" == "$version" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + python setup.py sdist + twine upload dist/* diff --git a/.gitignore b/.gitignore index 68bc17f..a665fee 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,19 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +*.grib +*.onnx +*.ckpt +*.swp +*.npy +*.download +? +?.* +foo +bar +*.grib +*.nc +*.npz +*.json +*.zarr diff --git a/README.md b/README.md index 5038584..e486177 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# ecml-tools \ No newline at end of file +# ecml-tools + +A package to hold various functions to support training of ML models on ECMWF data. diff --git a/ecml_tools/__init__.py b/ecml_tools/__init__.py new file mode 100644 index 0000000..44b886b --- /dev/null +++ b/ecml_tools/__init__.py @@ -0,0 +1,8 @@ +# (C) Copyright 2023 European Centre for Medium-Range Weather Forecasts. +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + +__version__ = "0.0.1" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ba71ad3 --- /dev/null +++ b/setup.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# (C) Copyright 2023 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. +# + + +import io +import os + +import setuptools + + +def read(fname): + file_path = os.path.join(os.path.dirname(__file__), fname) + return io.open(file_path, encoding="utf-8").read() + + +version = None +for line in read("ecml_tools/__init__.py").split("\n"): + if line.startswith("__version__"): + version = line.split("=")[-1].strip()[1:-1] + + +assert version + + +setuptools.setup( + name="ecml-tools", + version=version, + description="A package to hold various functions to support training of ML models on ECMWF data.", + long_description=read("README.md"), + long_description_content_type="text/markdown", + author="European Centre for Medium-Range Weather Forecasts (ECMWF)", + author_email="software.support@ecmwf.int", + license="Apache License Version 2.0", + url="https://github.com/ecmwf-lab/ecml-tools", + packages=setuptools.find_packages(), + include_package_data=True, + install_requires=[ + "zarr", + ], + extras_require={ + + }, + zip_safe=True, + keywords="tool", + entry_points={ + }, + classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Operating System :: OS Independent", + ], +) diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..fd69f0b --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1 @@ +# Empty for now diff --git a/tests/test_code.py b/tests/test_code.py new file mode 100644 index 0000000..cdfd941 --- /dev/null +++ b/tests/test_code.py @@ -0,0 +1,10 @@ +# (C) Copyright 2023 European Centre for Medium-Range Weather Forecasts. +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + + +def test_code(): + pass # Empty for now diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..02cc0f9 --- /dev/null +++ b/tox.ini @@ -0,0 +1,13 @@ +[isort] +profile = black + +[flake8] +; ignore = E226,E302,E41 +max-line-length = 120 +; exclude = tests/* +; See https://black.readthedocs.io/en/stable/the_black_code_style.html +exclude = + dev/* + experiments + ?.py +extend-ignore = E203