diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..a402bef --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,12 @@ +[bumpversion] +current_version = 0.2.1 +commit = True +tag = True + +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" + +[bumpversion:file:ddlpy/__init__.py] +search = __version__ = '{current_version}' +replace = __version__ = '{new_version}' diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 5564a1c..7491f5d 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,6 @@ -* Data Distributie Laag. Service from Rijkswaterstaat for distributing water quantity data. version: -* Python version: -* Operating System: +* ddlpy version: +* Python version: +* Operating System: ### Description @@ -9,7 +9,7 @@ Tell us what happened, what went wrong, and what you expected to happen. ### What I Did -``` +```python Paste the command(s) you ran and the output. If there was a crash, please include the traceback here. ``` diff --git a/.github/workflows/pypi-upload.yml b/.github/workflows/pypi-upload.yml new file mode 100644 index 0000000..6c4032b --- /dev/null +++ b/.github/workflows/pypi-upload.yml @@ -0,0 +1,27 @@ +name: pypi-upload + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e .[dev] + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m build + twine check dist/* + twine upload dist/* diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..c240b5d --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,44 @@ +name: pytest + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + + strategy: + fail-fast: false + matrix: + # we assume it also works for inbetween versions + python-version: ["3.8", "3.11", "3.12"] + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e .[dev] + - name: list env contents + run: | + pip list + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest -m "not requireslocaldata" --cov=ddlpy --cov-report xml --cov-report term + - uses: codecov/codecov-action@v1 diff --git a/.travis.yml b/.travis.yml index e6f06b2..9010c9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,5 +25,5 @@ deploy: secure: PLEASE_REPLACE_ME on: tags: true - repo: SiggyF/ddlpy + repo: Deltares/ddlpy python: 3.6 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 78cd5b2..c1026bf 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -15,7 +15,7 @@ Types of Contributions Report Bugs ~~~~~~~~~~~ -Report bugs at https://github.com/SiggyF/ddlpy/issues. +Report bugs at https://github.com/deltares/ddlpy/issues. If you are reporting a bug, please include: @@ -45,7 +45,7 @@ articles, and such. Submit Feedback ~~~~~~~~~~~~~~~ -The best way to send feedback is to file an issue at https://github.com/SiggyF/ddlpy/issues. +The best way to send feedback is to file an issue at https://github.com/deltares/ddlpy/issues. If you are proposing a feature: @@ -103,7 +103,7 @@ Before you submit a pull request, check that it meets these guidelines: your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check - https://travis-ci.org/SiggyF/ddlpy/pull_requests + https://travis-ci.org/deltares/ddlpy/pull_requests and make sure that the tests pass for all supported Python versions. Tips diff --git a/HISTORY.rst b/HISTORY.rst index 4fc52df..e051285 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,15 +4,15 @@ History UNRELEASED ------------------ -* improved nan filtering of measurements in https://github.com/openearth/ddlpy/pull/30 -* add `ddlpy.measurements_available()` check in https://github.com/openearth/ddlpy/pull/33 and https://github.com/openearth/ddlpy/pull/58 -* add `ddlpy.measurements_latest()` to retrieve latest measurements in https://github.com/openearth/ddlpy/pull/35 -* add optional time-sorting of returned measurements dataframe and made drop_duplicates optional in https://github.com/openearth/ddlpy/pull/37 -* add support for time strings in addition to `pd.Timestamp` and `dt.datetime` in https://github.com/openearth/ddlpy/pull/41 -* add `ddlpy.simplify_dataframe()` function which drops constant columns and adds the properties as attrs in https://github.com/openearth/ddlpy/pull/43 -* consistency improvements for `ddlpy.measurements()` output dataframe in https://github.com/openearth/ddlpy/pull/45 -* add distinction for Groepering (timeseries vs. extremes) to `ddlpy.locations()` dataframe in https://github.com/openearth/ddlpy/pull/49 -* drop `Tijdstip` column in `ddlpy.measurements()` output dataframe to avoid duplication with time index in https://github.com/openearth/ddlpy/pull/52 and https://github.com/openearth/ddlpy/pull/54 +* improved nan filtering of measurements in https://github.com/deltares/ddlpy/pull/30 +* add `ddlpy.measurements_available()` check in https://github.com/deltares/ddlpy/pull/33 and https://github.com/deltares/ddlpy/pull/58 +* add `ddlpy.measurements_latest()` to retrieve latest measurements in https://github.com/deltares/ddlpy/pull/35 +* add optional time-sorting of returned measurements dataframe and made drop_duplicates optional in https://github.com/deltares/ddlpy/pull/37 +* add support for time strings in addition to `pd.Timestamp` and `dt.datetime` in https://github.com/deltares/ddlpy/pull/41 +* add `ddlpy.simplify_dataframe()` function which drops constant columns and adds the properties as attrs in https://github.com/deltares/ddlpy/pull/43 +* consistency improvements for `ddlpy.measurements()` output dataframe in https://github.com/deltares/ddlpy/pull/45 +* add distinction for Groepering (timeseries vs. extremes) to `ddlpy.locations()` dataframe in https://github.com/deltares/ddlpy/pull/49 +* drop `Tijdstip` column in `ddlpy.measurements()` output dataframe to avoid duplication with time index in https://github.com/deltares/ddlpy/pull/52 and https://github.com/deltares/ddlpy/pull/54 0.1.0 (2019-01-03) ------------------ diff --git a/README.md b/README.md index 4b2700a..84c99cc 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,34 @@ +[![pypi-image](https://img.shields.io/pypi/v/ddlpy.svg)](https://pypi.python.org/pypi/ddlpy) +[![image](https://img.shields.io/travis/deltares/ddlpy.svg)](https://travis-ci.org/deltares/ddlpy) +[![Documentation Status](https://readthedocs.org/projects/rws-ddlpy/badge/?version=latest)](https://rws-ddlpy.readthedocs.io/en/latest/?badge=latest) +[![Updates](https://pyup.io/repos/github/deltares/ddlpy/shield.svg)](https://pyup.io/repos/github/deltares/ddlpy/) +[![pytest](https://github.com/Deltares/ddlpy/actions/workflows/pytest.yml/badge.svg?branch=main)](https://github.com/Deltares/ddlpy/actions/workflows/pytest.yml) +[![codecov](https://img.shields.io/codecov/c/github/deltares/ddlpy.svg?style=flat-square)](https://app.codecov.io/gh/deltares/ddlpy?displayType=list) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Deltares_ddlpy&metric=alert_status)](https://sonarcloud.io/summary/overall?id=Deltares_ddlpy) +[![Supported versions](https://img.shields.io/pypi/pyversions/ddlpy.svg)](https://pypi.org/project/ddlpy) +[![Downloads](https://img.shields.io/pypi/dm/ddlpy.svg)](https://pypistats.org/packages/ddlpy) + # ddlpy (D)ata (D)istributie (L)aag is a service from Rijkswaterstaat for distributing water quantity data. This package provides an API for python. -[![pypi-image](https://img.shields.io/pypi/v/rws-ddlpy.svg)](https://pypi.python.org/pypi/rws-ddlpy) - -[![image](https://img.shields.io/travis/openearth/ddlpy.svg)](https://travis-ci.org/openearth/ddlpy) - -[![Documentation Status](https://readthedocs.org/projects/rws-ddlpy/badge/?version=latest)](https://rws-ddlpy.readthedocs.io/en/latest/?badge=latest) - -[![Updates](https://pyup.io/repos/github/openearth/ddlpy/shield.svg)](https://pyup.io/repos/github/openearth/ddlpy/) - Service from Rijkswaterstaat for distributing water quantity data. -- Free software: GNU General Public License v3 - Documentation: . - See also https://github.com/wstolte/rwsapi for the R API. # Install -Make sure you have installed: - -* pandas -* numpy -* click -* python-dateutil>=2.8 +This text will be updated soon and a new pypi release will also happen soon. The latest ddlpy PyPI release is outdated, but it can be installed with: pip install rws-ddlpy The newest version is currently installed directly from github with: - pip install git+https://github.com/openearth/ddlpy + pip install git+https://github.com/deltares/ddlpy In the folder examples you will find the following files: @@ -41,8 +36,6 @@ In the folder examples you will find the following files: * 1_get_data_from_water_info_parallel.py -> Code to retrieve a bulk of observations per parameter and per station. -This code is parallelized; therefore, you can specify the number of processors you want to use. - The output of this code is the data in csv format. * 2_get_netcdf.py -> Code to transform the csv files run in the previous script into netcdf files. diff --git a/ddlpy/__init__.py b/ddlpy/__init__.py index 66b5c9a..45b5baf 100644 --- a/ddlpy/__init__.py +++ b/ddlpy/__init__.py @@ -4,7 +4,7 @@ __author__ = """Fedor Baart""" __email__ = 'fedor.baart@deltares.nl' -__version__ = '0.2.0' +__version__ = '0.2.1' from ddlpy.ddlpy import locations from ddlpy.ddlpy import (measurements, diff --git a/docs/installation.rst b/docs/installation.rst index 514af0d..fede821 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -32,13 +32,13 @@ You can either clone the public repository: .. code-block:: console - $ git clone git://github.com/SiggyF/ddlpy + $ git clone git://github.com/deltares/ddlpy Or download the `tarball`_: .. code-block:: console - $ curl -OL https://github.com/SiggyF/ddlpy/tarball/master + $ curl -OL https://github.com/deltares/ddlpy/tarball/master Once you have a copy of the source, you can install it with: @@ -47,5 +47,5 @@ Once you have a copy of the source, you can install it with: $ python setup.py install -.. _Github repo: https://github.com/SiggyF/ddlpy -.. _tarball: https://github.com/SiggyF/ddlpy/tarball/master +.. _Github repo: https://github.com/deltares/ddlpy +.. _tarball: https://github.com/deltares/ddlpy/tarball/master diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6cccdf2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,78 @@ +[build-system] +requires = ["setuptools>=64.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "ddlpy" +version = "0.2.1" +maintainers = [ + { name = "Fedor Baart", email = "fedor.baart@deltares.nl"}, + { name = "Jelmer Veenstra", email = "jelmer.veenstra@deltares.nl"}, +] +description = "Service from Rijkswaterstaat for distributing water quantity data." +readme = "README.md" +keywords = ["ddlpy"] +license = { text = "GPLv3" } +requires-python = ">=3.8" +dependencies = [ + #numpy 1.21 is EOL since june 2023 + "numpy>=1.22", + "pandas", + "python-dateutil>=2.8", + "tqdm", + "click", +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", # TODO: update this + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] + +[project.urls] +Home = "https://github.com/deltares/ddlpy" +Code = "https://github.com/deltares/ddlpy" +Issues = "https://github.com/deltares/ddlpy/issues" + +[project.optional-dependencies] +dev = [ #TODO: maybe remove some of these + "bump2version>=0.5.11", + "flake8", + "pytest>=3.8.2", + "pytest-cov", + "twine", + "build", + "watchdog>=0.9.0", + "flake8>=3.5.0", + "tox>=3.5.2", + "coverage>=4.5.1", + "Sphinx>=1.8.1", + "twine>=1.12.1", + "pytest-runner>=4.2", +] +examples = [ + "jupyter", + "notebook", +] + +[project.scripts] +ddlpy = "ddlpy.cli:cli" + +[tool.setuptools] +packages = ["ddlpy"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +addopts = "--durations=0" + +[tool.flake8] +exclude = "docs" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b76db30..0000000 --- a/setup.cfg +++ /dev/null @@ -1,25 +0,0 @@ -[bumpversion] -current_version = 0.2.0 -commit = True -tag = True - -[bumpversion:file:setup.py] -search = version='{current_version}' -replace = version='{new_version}' - -[bumpversion:file:ddlpy/__init__.py] -search = __version__ = '{current_version}' -replace = __version__ = '{new_version}' - -[bdist_wheel] -universal = 1 - -[flake8] -exclude = docs - -[aliases] -# Define setup.py command aliases here -test = pytest - -[tool:pytest] -collect_ignore = ['setup.py'] diff --git a/setup.py b/setup.py deleted file mode 100755 index 556c857..0000000 --- a/setup.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -"""The setup script.""" - -from setuptools import setup, find_packages - -with open('README.md') as readme_file: - readme = readme_file.read() - -with open('HISTORY.rst') as history_file: - history = history_file.read() - -with open('requirements.txt') as requirements_file: - requirements = requirements_file.readlines() - -setup_requirements = ['pytest-runner', ] - -test_requirements = ['pytest', ] - -setup( - author="Fedor Baart", - author_email='fedor.baart@deltares.nl', - classifiers=[ - 'Development Status :: 2 - Pre-Alpha', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - ], - description="Service from Rijkswaterstaat for distributing water quantity data.", - entry_points={ - 'console_scripts': [ - 'ddlpy=ddlpy.cli:cli', - ], - }, - install_requires=requirements, - license="GNU General Public License v3", - long_description=readme, - long_description_content_type='text/markdown', - include_package_data=True, - keywords='ddlpy', - name='ddlpy', - packages=find_packages(include=['ddlpy']), - setup_requires=setup_requirements, - test_suite='tests', - tests_require=test_requirements, - url='https://github.com/openearth/ddlpy', - version='0.2.0', - zip_safe=False, -) diff --git a/tests/test_ddlpy.py b/tests/test_ddlpy.py index e2b7d9a..cc85a43 100755 --- a/tests/test_ddlpy.py +++ b/tests/test_ddlpy.py @@ -77,7 +77,7 @@ def test_measurements_long(location): def test_measurements_sorted(location): - """https://github.com/openearth/ddlpy/issues/27""" + """https://github.com/deltares/ddlpy/issues/27""" # input parameters start_date = dt.datetime(2019,11,24) end_date = dt.datetime(2019,12,5) @@ -96,7 +96,7 @@ def test_measurements_sorted(location): def test_measurements_duplicated(location): """ WALSODN 2010 contains all values three times, ddlpy drops duplicates - https://github.com/openearth/ddlpy/issues/24 + https://github.com/deltares/ddlpy/issues/24 if the data is cleaned in ddl, this test will fail and can be removed or adjusted """ locations = ddlpy.locations() @@ -114,7 +114,7 @@ def test_measurements_duplicated(location): def test_measurements_remove_duplicates_nottoomuch(location): """ - to prevent issue https://github.com/openearth/ddlpy/issues/53 + to prevent issue https://github.com/deltares/ddlpy/issues/53 """ start_date = dt.datetime(2014, 1, 1) end_date = dt.datetime(2014, 1, 7)