From b60a35a661689464c8138139297cac18f15f9541 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Fri, 14 Jan 2022 20:55:37 +0100 Subject: [PATCH 01/17] move to github actions --- .github/workflows/ci.yml | 50 +++++++++++++++++++ .travis.yml | 23 --------- ...irements.travis.txt => requirements.ci.txt | 0 setup.py | 5 +- 4 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml rename requirements.travis.txt => requirements.ci.txt (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..60ce4f0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: ttim + +on: + # Trigger the workflow on push or pull request on master + push: + branches: + - ci + pull_request: + branches: + - ci + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8, 3.9] + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.ci.txt ]; then pip install -r requirements.ci.txt; fi + pip install flake8 pytest + pip install codecov + pip install pytest-cov + pip install coveralls + pip install -e . + + - 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=80 --statistics + + - name: Run tests only + run: | + py.test ./tests + + # - name: Publish to coveralls.io + # uses: coverallsapp/github-action@v1.1.2 + # with: + # github-token: ${{ github.token }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9ae998e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -sudo: required -language: python - -matrix: - include: - - os: linux - dist: xenial - python: "3.7" - sudo: true - fast_finish: true - -install: - - pip install -r requirements.travis.txt - - pip install -e . - - pip install --upgrade pip - - pip install codecov pytest pytest-cov coveralls - - pip install jupyter - -script: - - pytest --cov=ttim tests/ - -after_success: - - coveralls diff --git a/requirements.travis.txt b/requirements.ci.txt similarity index 100% rename from requirements.travis.txt rename to requirements.ci.txt diff --git a/setup.py b/setup.py index 0af4925..7fefef1 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ from setuptools import setup + version = {} with open("ttim/version.py") as fp: exec(fp.read(), version) @@ -17,12 +18,14 @@ version=version["__version__"], description="Transient multi-layer AEM Model", long_description=l_d, + long_description_content_type='text/markdown', author="Mark Bakker", author_email="markbak@gmail.com", url="https://github.com/mbakker7/ttim", license="MIT", packages=["ttim"], python_requires='>=3.7', - install_requires=["numpy>=1.17", "scipy>=1.5", "numba>=0.5", "matplotlib>=3.1", "lmfit>=1.0", "pandas>=1.1"], + install_requires=["numpy>=1.17", "scipy>=1.5", "numba>=0.5", + "matplotlib>=3.1", "lmfit>=1.0", "pandas>=1.1"], classifiers=['Topic :: Scientific/Engineering :: Hydrology'], ) From e7581db229f3aa4aa796d5c2e6ee5e9235d52320 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Fri, 14 Jan 2022 20:57:51 +0100 Subject: [PATCH 02/17] turn off flake8 check --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60ce4f0..4e9f4a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,14 +33,14 @@ jobs: pip install coveralls pip install -e . - - 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=80 --statistics + # - 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=80 --statistics - - name: Run tests only + - name: Run tests run: | py.test ./tests From 43f2c908577f2c4c2d51dafa1220b5a13aed503f Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Fri, 14 Jan 2022 21:16:54 +0100 Subject: [PATCH 03/17] fix notebook tests add pytest.ini file add jupyter to requirements --- pytest.ini | 2 ++ tests/test_notebooks.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..15d8193 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts=--durations=0 -v \ No newline at end of file diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py index 549c347..718d9ad 100644 --- a/tests/test_notebooks.py +++ b/tests/test_notebooks.py @@ -1,6 +1,9 @@ import os +import shutil +import subprocess +import tempfile + import pytest -import shutil, tempfile nbdir = os.path.join('notebooks') From 3a5e917615d3d0906dcd7d76bddcb308c8061b55 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Fri, 14 Jan 2022 21:20:10 +0100 Subject: [PATCH 04/17] add jupyter in requirements --- requirements.ci.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.ci.txt b/requirements.ci.txt index 905d0cf..af94fdd 100644 --- a/requirements.ci.txt +++ b/requirements.ci.txt @@ -3,4 +3,5 @@ scipy>=1.5 numba>=0.5 matplotlib>=3.1 lmfit>=1.0 -pandas>=1.1 \ No newline at end of file +pandas>=1.1 +jupyter>=1.0.0 \ No newline at end of file From 9220c5cfda78b24dd39b4ebf2044db1021677c15 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Fri, 14 Jan 2022 21:37:42 +0100 Subject: [PATCH 05/17] max version for matplotlib for failing notebooks --- requirements.ci.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.ci.txt b/requirements.ci.txt index af94fdd..41dcf70 100644 --- a/requirements.ci.txt +++ b/requirements.ci.txt @@ -1,7 +1,7 @@ numpy>=1.17 scipy>=1.5 numba>=0.5 -matplotlib>=3.1 +matplotlib>=3.1,<3.5.0 lmfit>=1.0 pandas>=1.1 jupyter>=1.0.0 \ No newline at end of file From cb974667635900a189a3a072c8cd4998252cf72f Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Sat, 15 Jan 2022 17:33:49 +0100 Subject: [PATCH 06/17] set ci to run for master branch add badge to readme turn on coveralls task, not sure if it will work yet... --- .github/workflows/ci.yml | 24 ++++++++++++------------ README.md | 8 ++++---- pytest.ini | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e9f4a4..b8ff361 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,10 +4,10 @@ on: # Trigger the workflow on push or pull request on master push: branches: - - ci + - master pull_request: branches: - - ci + - master jobs: test: @@ -33,18 +33,18 @@ jobs: pip install coveralls pip install -e . - # - 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=80 --statistics + - 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=80 --statistics - name: Run tests run: | py.test ./tests - # - name: Publish to coveralls.io - # uses: coverallsapp/github-action@v1.1.2 - # with: - # github-token: ${{ github.token }} + - name: Publish to coveralls.io + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 12934e1..2a493fb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Linux+/+macOS](https://travis-ci.org/mbakker7/ttim.svg?branch=master)](https://travis-ci.org/mbakker7/ttim) +[![ttim](https://github.com/mbakker7/ttim/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mbakker7/ttim/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/mbakker7/ttim/badge.svg?branch=master)](https://coveralls.io/github/mbakker7/ttim?branch=master) # TTim, A Multi-Layer, Transient, Analytic Element Model @@ -16,7 +16,7 @@ TTim is coded in Python and uses numba to speed up evaluation of the line elemen ## Latest version New in version 0.5: -* FORTRAN extension has been ported to Python and numba (many thanks to Davíd Brakenhoff) +* FORTRAN extension has been ported to Python and numba (many thanks to Davíd Brakenhoff) * Python invlap routine (again with numba) ported from routine by Kris Kuhlman * New invlap routine requires fewer terms in inverse Laplace transform (M=10 is usually enough) * Calibrate now works on ranges of parameters. @@ -39,7 +39,7 @@ To update TTim type: pip install ttim --upgrade -To uninstall TTi type: +To uninstall TTim type: pip uninstall ttim @@ -52,6 +52,6 @@ To uninstall TTi type: Some of the papers that you may want to cite when using TTim are: -* M. Bakker. 2013. Semi-analytic modeling of transient multi-layer flow with TTim. Hydrogeology Journal, 21: 935Ð943. +* M. Bakker. 2013. Semi-analytic modeling of transient multi-layer flow with TTim. Hydrogeology Journal, 21: 935�943. * M .Bakker. 2013. Analytic modeling of transient multi-layer flow. In: Advances in Hydrogeology, edited by P Mishra and K Kuhlman, Springer, Heidelberg, 95-114. diff --git a/pytest.ini b/pytest.ini index 15d8193..97b6575 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,2 @@ [pytest] -addopts=--durations=0 -v \ No newline at end of file +addopts=--durations=0 -v --cov \ No newline at end of file From 636a595014072ad454ccfa7ed71f491fdf85cf6c Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Sat, 15 Jan 2022 17:51:28 +0100 Subject: [PATCH 07/17] ignore aquifernew in flake8 check read markdown readme differently, maybe helps to make it show up in pypi later --- setup.py | 11 +++++------ ttim/aquifernew.py | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 7fefef1..7efe4a8 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +from os import path + from setuptools import setup version = {} @@ -5,12 +7,9 @@ exec(fp.read(), version) l_d = "" -try: - import pypandoc - - l_d = pypandoc.convert("README.md", "rst") -except: - pass +this_directory = path.abspath(path.dirname(__file__)) +with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f: + l_d = f.read() setup( diff --git a/ttim/aquifernew.py b/ttim/aquifernew.py index 4e2f4a6..b71566b 100644 --- a/ttim/aquifernew.py +++ b/ttim/aquifernew.py @@ -1,3 +1,4 @@ +# flake8: noqa import numpy as np import matplotlib.pyplot as plt import inspect # Used for storing the input From 892678aa8a56ac2318a90a67d46269bd08a60c58 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Sat, 15 Jan 2022 20:42:55 +0100 Subject: [PATCH 08/17] ignore circinhom for flake8 --- ttim/circinhom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ttim/circinhom.py b/ttim/circinhom.py index b1cdd65..b44f911 100644 --- a/ttim/circinhom.py +++ b/ttim/circinhom.py @@ -1,3 +1,4 @@ +# flake8: noqa import numpy as np from scipy.special import kv, iv # Needed for K1 in Well class, and in CircInhom from .aquifer import AquiferData From 5872996fd45f0d6745f341a0693ad96c71b8f41a Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Sat, 15 Jan 2022 20:52:41 +0100 Subject: [PATCH 09/17] ignore bessel comparison test script --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 97b6575..c2dd30c 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,2 @@ [pytest] -addopts=--durations=0 -v --cov \ No newline at end of file +addopts=--durations=0 --cov-report xml:coverage.xml --cov ttim -v --ignore=test_bessel.py \ No newline at end of file From 20882ab98ed90a054cad6f7bccd29a8730d7c9b4 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Sat, 15 Jan 2022 21:03:50 +0100 Subject: [PATCH 10/17] turn off coveralls reporting for now --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8ff361..71bec50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: run: | py.test ./tests - - name: Publish to coveralls.io - uses: coverallsapp/github-action@v1.1.2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Publish to coveralls.io + # uses: coverallsapp/github-action@v1.1.2 + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} From 0f0d0adcecb1d685e745146c9dbc566a65b3e826 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Mon, 17 Jan 2022 12:22:33 +0100 Subject: [PATCH 11/17] add coverage reporting --- .coveragerc | 8 ++++++++ .github/workflows/ci.yml | 8 ++++---- pytest.ini | 4 +++- tests/test_notebooks.py | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..32631c7 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,8 @@ +[run] +omit = + # omit these files + ttiml/circinhom.py + # omit anything in a .local directory anywhere + # */.local/* + # omit everything in /usr + # /usr/* \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71bec50..f70d70c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: run: | py.test ./tests - # - name: Publish to coveralls.io - # uses: coverallsapp/github-action@v1.1.2 - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish to coveralls.io + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/pytest.ini b/pytest.ini index c2dd30c..6d2e71e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,4 @@ [pytest] -addopts=--durations=0 --cov-report xml:coverage.xml --cov ttim -v --ignore=test_bessel.py \ No newline at end of file +addopts=--durations=0 --cov ttim -v --ignore=test_bessel.py +markers = + notebooks: run notebooks \ No newline at end of file diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py index 718d9ad..a786887 100644 --- a/tests/test_notebooks.py +++ b/tests/test_notebooks.py @@ -27,6 +27,7 @@ def get_jupyter_kernel(): return kernel +@pytest.mark.notebooks @pytest.mark.parametrize("fn", get_notebooks()) def test_notebook(fn): From 5d7fe922f7146f40c07bd71971f94d147a9c0490 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Mon, 17 Jan 2022 12:41:42 +0100 Subject: [PATCH 12/17] ignore files in coverage --- .coveragerc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.coveragerc b/.coveragerc index 32631c7..adb85a2 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,8 +1,7 @@ [run] omit = # omit these files - ttiml/circinhom.py - # omit anything in a .local directory anywhere - # */.local/* - # omit everything in /usr - # /usr/* \ No newline at end of file + ttim/circinhom.py + ttim/besselnumba_total.py + ttim/aquifernew.py + ttim/kuhlman_invlap.py From c4dfd338943322e0b8c37e5f3a23b199a59899d7 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Mon, 17 Jan 2022 12:45:16 +0100 Subject: [PATCH 13/17] ignore files in coverage --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 6d2e71e..c8b3013 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] -addopts=--durations=0 --cov ttim -v --ignore=test_bessel.py +addopts=--durations=0 -v --cov ttim --cov-config=.coveragerc --ignore=test_bessel.py markers = notebooks: run notebooks \ No newline at end of file From 030887a6827f30e160e70be69fceb09401dac464 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Mon, 17 Jan 2022 13:02:59 +0100 Subject: [PATCH 14/17] try again --- .coveragerc | 1 - 1 file changed, 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index adb85a2..c0bbe2b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,5 @@ [run] omit = - # omit these files ttim/circinhom.py ttim/besselnumba_total.py ttim/aquifernew.py From 0bb4c23dfa07fbb34f1e8694dc1e04fc5863bc71 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Tue, 18 Jan 2022 09:42:08 +0100 Subject: [PATCH 15/17] one more attempt --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index c8b3013..7e6285e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] -addopts=--durations=0 -v --cov ttim --cov-config=.coveragerc --ignore=test_bessel.py +addopts=--durations=0 -v --cov ttim/ --cov-config=.coveragerc --ignore=test_bessel.py markers = notebooks: run notebooks \ No newline at end of file From 739db44feca8d06abf4e082627cd3b04d9427e0f Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Tue, 18 Jan 2022 11:19:29 +0100 Subject: [PATCH 16/17] add pypi release workflow --- .github/workflows/python-publish.yml | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..4e1ef42 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflows 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: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* From c2c226d5b6c6648c44be45da6e571abf3e5dbf00 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Tue, 18 Jan 2022 14:51:40 +0100 Subject: [PATCH 17/17] get coverage right! add pypi badge --- .coveragerc | 8 ++++---- README.md | 1 + pytest.ini | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.coveragerc b/.coveragerc index c0bbe2b..1eda354 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,6 @@ [run] omit = - ttim/circinhom.py - ttim/besselnumba_total.py - ttim/aquifernew.py - ttim/kuhlman_invlap.py + */ttim/circinhom.py + */ttim/besselnumba_total.py + */ttim/aquifernew.py + */ttim/kuhlman_invlap.py diff --git a/README.md b/README.md index 2a493fb..b244b96 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![ttim](https://github.com/mbakker7/ttim/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mbakker7/ttim/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/mbakker7/ttim/badge.svg?branch=master)](https://coveralls.io/github/mbakker7/ttim?branch=master) +![PyPI](https://img.shields.io/pypi/v/ttim?color=green) # TTim, A Multi-Layer, Transient, Analytic Element Model diff --git a/pytest.ini b/pytest.ini index 7e6285e..c8b3013 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] -addopts=--durations=0 -v --cov ttim/ --cov-config=.coveragerc --ignore=test_bessel.py +addopts=--durations=0 -v --cov ttim --cov-config=.coveragerc --ignore=test_bessel.py markers = notebooks: run notebooks \ No newline at end of file