From ffb0f59f4f1f3a16097ecda54d9d3e07bb6100d7 Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Wed, 21 Jul 2021 10:57:57 -0700 Subject: [PATCH 1/5] switch from Travis to GitHub actions CI --- .github/workflows/ci.yaml | 94 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 60 ------------------------- README.rst | 4 +- 3 files changed, 96 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..322729cd --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,94 @@ +name: CI + +on: + # run once a day at 5:55 UTC + schedule: + - cron: "55 5 * * *" + push: + branches: + - "develop" + - "master" + pull_request: + branches: + - "develop" + +concurrency: + group: "${{ github.ref }}-${{ github.head_ref }}" + cancel-in-progress: true + +# TODO: test different OS (but difficult with GROMACS versions) +# for right now: test on Linux only +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + #os: [ubuntu-latest, macos-latest] + python-version: [2.7, 3.8] + #python-version: [2.7, 3.6, 3.7, 3.8, 3.9] + gromacs-version: ["4.6.5", "2019.1"] + #gromacs-version: ["4.6.5", "2019.1", "2021.1"] + env: + MPLBACKEND: agg + + + steps: + - uses: actions/checkout@v2 + + - uses: conda-incubator/setup-miniconda@v2 + with: + python-version: ${{ matrix.python-version }} + auto-update-conda: true + mamba-version: "*" + channels: conda-forge,bioconda,defaults + channel-priority: true + show-channel-urls: true + + - name: Conda info + shell: bash -l {0} + run: | + conda info + conda list + conda config --show-sources + conda config --show + + - name: Python version + shell: bash -l {0} + run: | + python -c "import sys; print(sys.version)" + + - name: Install package dependencies + shell: bash -l {0} + run: | + mamba install six numpy scipy matplotlib pandas scikit-learn pyyaml mdanalysis numexpr + python -m pip install --no-deps numkit gromacswrapper + python -m pip install alchemlyb + + - name: Install pytest+plugins and pybol + shell: bash -l {0} + run: | + mamba install pytest pytest-pep8 pytest-cov codecov + python -m pip install pybol + + - name: Install GROMACS (${{ matrix.gromacs-version }}) + shell: bash -l {0} + run: | + mamba install 'gromacs==${{ matrix.gromacs-version }}' pocl + + - name: Install package + shell: bash -l {0} + run: | + python -m pip install --no-deps . + + - name: Run tests + shell: bash -l {0} + run: | + pytest -v --durations=20 --cov=mdpow --cov-report=xml ./mdpow/tests + + - name: Codecov + uses: codecov/codecov-action@v1 + with: + file: ./coverage.xml + fail_ci_if_error: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 60a9b884..00000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -language: generic -sudo: false - -# whitelist -branches: - only: - - master - - develop - - testing-gromacs-5-travis - -env: - global: - - PYTHON_VERSION=2.7 - - CODECOV=true - - PYTEST_FLAGS="-v --cov=mdpow" - - PYTEST_LIST="mdpow/tests" - - MAIN_CMD="pytest ${PYTEST_LIST}" - - SETUP_CMD="${PYTEST_FLAGS}" - - BUILD_CMD="pip install -v ." - - CONDA_DEPENDENCIES="six matplotlib pandas gromacs" - # Gromacs 2018 packages from bioconda require conda-forge for - # dependency, see https://bioconda.github.io/#set-up-channels - - CONDA_CHANNELS="defaults conda-forge bioconda" - - CONDA_CHANNEL_PRIORITY=True - - PIP_DEPENDENCIES="numkit codecov pybol" - - NUMPY_VERSION=stable - - MPLBACKEND=agg - - matrix: - # use ci-helper's PACKAGENAME_VERSION magic to pin the 'gromacs' package - - GROMACS_VERSION=4.6.5 PYTHON_VERSION=2.7 - - GROMACS_VERSION=2019.1 PYTHON_VERSION=2.7 - SETUP_CMD="${SETUP_CMD}" - - -matrix: - fast_finish: true - - include: - # see Gromacs packages on bioconda https://anaconda.org/bioconda/gromacs/files - - os: osx - env: GROMACS_VERSION=2019.1 PYTHON_VERSION=2.7 - - -install: - - git clone --depth 1 git://github.com/astropy/ci-helpers.git - - source ci-helpers/travis/setup_conda.sh - - eval $BUILD_CMD - -script: - - cd ${TRAVIS_BUILD_DIR} - - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then ulimit -S -n 2048; fi - - echo $MAIN_CMD $SETUP_CMD - - eval $MAIN_CMD $SETUP_CMD - -after_success: - - | - if [[ $CODECOV == 'true' ]]; then \ - codecov; \ - fi diff --git a/README.rst b/README.rst index c5db41a0..43990476 100644 --- a/README.rst +++ b/README.rst @@ -81,9 +81,9 @@ Footnotes .. [#GromacsWrapperNote] The package is built on top of the GromacsWrapper_ framework (which is automatically installed). -.. |build| image:: https://travis-ci.org/Becksteinlab/MDPOW.svg?branch=develop +.. |build| image:: https://github.com/Becksteinlab/MDPOW/actions/workflows/ci.yaml/badge.svg?branch=develop :alt: Build Status - :target: https://travis-ci.org/Becksteinlab/MDPOW + :target: https://github.com/Becksteinlab/MDPOW/actions/workflows/ci.yaml .. |cov| image:: https://codecov.io/github/Becksteinlab/MDPOW/coverage.svg?branch=develop :alt: Coverage Status From 6d86f7b571cc57cbe1ab433e9e9e5646c833762f Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Wed, 21 Jul 2021 11:00:54 -0700 Subject: [PATCH 2/5] fixes to make tests pass locally - fix encoding issues in file - allow GROMACS to choose number of threads in most of the tests to avoid problems when GROMACS was not compiled to change thread numbers (ERROR: Setting the total number of threads is only supported with thread-MPI but this version of GROMACS was not compiled with tMPI) --- mdpow/forcefields.py | 3 ++- mdpow/tests/test_runinput.py | 2 +- mdpow/tests/testing_resources/states/base/runinput.yml | 4 +--- mdpow/tests/testing_resources/states/md_npt/runinput.yml | 5 ++--- .../test_configurations/altered_runinput.yml | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/mdpow/forcefields.py b/mdpow/forcefields.py index 339d229a..c0a570b2 100644 --- a/mdpow/forcefields.py +++ b/mdpow/forcefields.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # POW package __init__.py # Copyright (c) 2012 Oliver Beckstein # Released under the GNU Public License 3 (or higher, your choice) @@ -146,7 +147,7 @@ def get_water_model(watermodel=DEFAULT_WATER_MODEL): #: Other solvents (not water, see :data:`GROMACS_WATER_MODELS` for those). new_octanol = '''Zangi R (2018) Refinement of the OPLSAA force-field - for liquid alcohols.; ACS Omega 3(12):18089–18099. + for liquid alcohols.; ACS Omega 3(12):18089-18099. doi: 10.1021/acsomega.8b03132''' OPLS_SOLVENT_MODELS = { diff --git a/mdpow/tests/test_runinput.py b/mdpow/tests/test_runinput.py index 39e00f30..a9dca87d 100644 --- a/mdpow/tests/test_runinput.py +++ b/mdpow/tests/test_runinput.py @@ -79,7 +79,7 @@ class TestAlteredConfig(object): 'stepout': 12000, 'verbose': False, 'nice': 12, - 'maxthreads': 3 + 'maxthreads': 1 } } diff --git a/mdpow/tests/testing_resources/states/base/runinput.yml b/mdpow/tests/testing_resources/states/base/runinput.yml index 32f179ca..dec9e83f 100644 --- a/mdpow/tests/testing_resources/states/base/runinput.yml +++ b/mdpow/tests/testing_resources/states/base/runinput.yml @@ -119,8 +119,6 @@ mdrun: # report progress verbosely (True is -v) nice: 19 # nicel level - maxthreads: 3 + maxthreads: None # maximum number of threads (-nt), 0 or None lets mdrun # automatically choose - # For testing on travis, needs to be either 3 or 1. - # See https://github.com/Becksteinlab/MDPOW/pull/77 diff --git a/mdpow/tests/testing_resources/states/md_npt/runinput.yml b/mdpow/tests/testing_resources/states/md_npt/runinput.yml index e8827876..08b5869d 100644 --- a/mdpow/tests/testing_resources/states/md_npt/runinput.yml +++ b/mdpow/tests/testing_resources/states/md_npt/runinput.yml @@ -119,8 +119,7 @@ mdrun: # report progress verbosely (True is -v) nice: 19 # nicel level - maxthreads: 3 + maxthreads: None # maximum number of threads (-nt), 0 or None lets mdrun # automatically choose - # For testing on travis, needs to be either 3 or 1. - # See https://github.com/Becksteinlab/MDPOW/pull/77 + diff --git a/mdpow/tests/testing_resources/test_configurations/altered_runinput.yml b/mdpow/tests/testing_resources/test_configurations/altered_runinput.yml index 47710fe3..89f4abbe 100644 --- a/mdpow/tests/testing_resources/test_configurations/altered_runinput.yml +++ b/mdpow/tests/testing_resources/test_configurations/altered_runinput.yml @@ -119,5 +119,5 @@ mdrun: # report progress verbosely (True is -v) nice: 12 # nicel level - maxthreads: 3 + maxthreads: 1 # maximum number of threads (-nt), 0 or None lets mdrun automatically choose From c8f518ecf885b2e4d0e6764b3434bf91a71c5c4d Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Wed, 21 Jul 2021 16:43:15 -0700 Subject: [PATCH 3/5] disable testing mixed solvent for GROMACS < 2019 See #111. --- .github/workflows/ci.yaml | 6 +++--- mdpow/tests/test_solvation.py | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 322729cd..66de8ca7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,10 +26,10 @@ jobs: matrix: os: [ubuntu-latest] #os: [ubuntu-latest, macos-latest] - python-version: [2.7, 3.8] + python-version: [2.7] + #python-version: [2.7, 3.8] #python-version: [2.7, 3.6, 3.7, 3.8, 3.9] - gromacs-version: ["4.6.5", "2019.1"] - #gromacs-version: ["4.6.5", "2019.1", "2021.1"] + gromacs-version: ["4.6.5", "2019.1", "2021.1"] env: MPLBACKEND: agg diff --git a/mdpow/tests/test_solvation.py b/mdpow/tests/test_solvation.py index 8060486c..93fab3a1 100644 --- a/mdpow/tests/test_solvation.py +++ b/mdpow/tests/test_solvation.py @@ -52,7 +52,12 @@ def test_solvation_octanol(setup, ff): def test_solvation_cyclohexane(setup): solvation(setup, "cyclohexane") -@pytest.mark.xfail("gromacs.release().startswith('2019')") +@pytest.mark.xfail(gromacs.release.startswith('4') + or gromacs.release.startswith('5') + or gromacs.release.startswith('2016') + or gromacs.release.startswith('2018'), + reason="GROMACS < 2019 cannot easily work with mixed solvents " + "(see issue #111)") @pytest.mark.parametrize("ff", ['OPLS-AA', 'CHARMM', 'AMBER']) def test_solvation_wetoctanol(setup, ff): solvation(setup, "wetoctanol", ff) From c2b8a9f9662c9813ce86f596262ba668d41bf3cd Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Wed, 21 Jul 2021 17:20:09 -0700 Subject: [PATCH 4/5] expand CI testing - run on macOS-latest - include GROMACS 2018 --- .github/workflows/ci.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 66de8ca7..1ddf5a67 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,20 +16,27 @@ concurrency: group: "${{ github.ref }}-${{ github.head_ref }}" cancel-in-progress: true -# TODO: test different OS (but difficult with GROMACS versions) -# for right now: test on Linux only jobs: test: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest] - #os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macOS-latest] python-version: [2.7] #python-version: [2.7, 3.8] #python-version: [2.7, 3.6, 3.7, 3.8, 3.9] - gromacs-version: ["4.6.5", "2019.1", "2021.1"] + gromacs-version: ["4.6.5", "2018.6", "2019.1", "2021.1"] + # only test one GROMACS version on macOS to keep the testing + # matrix manageable + exclude: + - os: macOS-latest + gromacs-version: "4.6.5" + - os: macOS-latest + gromacs-version: "2018.6" + - os: macOS-latest + gromacs-version: "2019.1" + env: MPLBACKEND: agg From 9570cbccbc0757933b77fa8655cb45d386b768df Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Wed, 21 Jul 2021 17:20:33 -0700 Subject: [PATCH 5/5] enable mixed solvent test for GROMACS 2018 --- mdpow/tests/test_solvation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mdpow/tests/test_solvation.py b/mdpow/tests/test_solvation.py index 93fab3a1..e4d4da8f 100644 --- a/mdpow/tests/test_solvation.py +++ b/mdpow/tests/test_solvation.py @@ -54,9 +54,8 @@ def test_solvation_cyclohexane(setup): @pytest.mark.xfail(gromacs.release.startswith('4') or gromacs.release.startswith('5') - or gromacs.release.startswith('2016') - or gromacs.release.startswith('2018'), - reason="GROMACS < 2019 cannot easily work with mixed solvents " + or gromacs.release.startswith('2016'), + reason="GROMACS < 2018 cannot easily work with mixed solvents " "(see issue #111)") @pytest.mark.parametrize("ff", ['OPLS-AA', 'CHARMM', 'AMBER']) def test_solvation_wetoctanol(setup, ff):