From c655df64059974d44d20dab0aadf544727ffca06 Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Tue, 8 Mar 2022 14:26:55 -0600 Subject: [PATCH] Update CI, fix compatibility with OpenMM 7.7 (#249) * Only test against OpenFF Toolkit 0.10.3 and on Python 3.7+ * Tinker with CI * Update Python versions * Try `--use-pep517` * Pin to Openmm 7.6 * Debug: Turn off switching function in ALL cases * Attempt to isolate CustomNonbondedForce.setUseSwitchingFunction * Isolate mmopts * Debug * Focus tests more on old failures * Drop tinker stuff * Fix typo * Remove some debug code * Revert debug state * Fix syntax, add back Python 3.6 * Update src/openmmio.py Co-authored-by: Jeff Wagner * Allow a version of the toolkit compatible with Python 3.6 Versions 0.10.1 and 0.10.2 are broken but not yet off of conda-forge, so the pinning here MUST ensure that old builds are 0.10.0 or OLDER * Unpin OpenMM * Allow old pip * Fix syntax in version constraints * Install dataclasses backport for networkx Co-authored-by: Jeff Wagner --- .github/workflows/ci.yml | 50 ++++++++++++++----------------- devtools/conda-envs/test_env.yaml | 12 +++----- src/openmmio.py | 13 +++++++- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9202847cb..909b06ccc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,10 @@ on: branches: - "master" +defaults: + run: + shell: bash -l {0} + jobs: test: runs-on: ${{ matrix.os }} @@ -18,9 +22,11 @@ jobs: - macOS-latest - ubuntu-latest python-version: - - 3.6 - - 3.7 - - 3.8 + - "3.6" + - "3.7" + - "3.8" + - "3.9" + env: CI_OS: ${{ matrix.os }} PYVER: ${{ matrix.python-version }} @@ -30,11 +36,12 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - uses: conda-incubator/setup-miniconda@v2.1.1 + - name: Install dependencies with Minicondna + uses: conda-incubator/setup-miniconda@v2.1.1 with: python-version: ${{ matrix.python-version }} - activate-environment: test - channel-priority: true + mamba-version: "*" + activate-environment: forcebalance-test environment-file: devtools/conda-envs/test_env.yaml auto-activate-base: false @@ -46,20 +53,12 @@ jobs: ulimit -a - name: Environment Information - shell: bash -l {0} run: | conda info --all conda list - - name: Install OpenFF stack and OpenEye on Python 3.6+ - if: ${{ matrix.python-version != 2.7}} - shell: bash -l {0} - run: | - conda install openff-toolkit -c conda-forge -y - # Need to replace ndcctools with this block # - name: Install Work Queue -# shell: bash -l {0} # run: | # wget https://raw.githubusercontent.com/leeping/forcebalance/master/tools/install-cctools.sh # bash install-cctools.sh @@ -67,12 +66,6 @@ jobs: # python -c "import work_queue" # export PATH="$GITHUB_WORKSPACE/opt/cctools/current/bin:$PATH" - - name: Install GROMACS - shell: bash -l {0} - run: | - # This will not install double precision, needs to be replaced with a fresh build - conda install gromacs=2019.1 -c bioconda -c conda-forge -y - - name: Install Tinker run: | if [[ "$CI_OS" == 'ubuntu-latest' ]]; then @@ -101,26 +94,27 @@ jobs: tar xvjf targets.tar.bz2 cd ../../ + - name: Install backport of dataclasses + if: ${{ matrix.python-version == 3.6}} + run: | + pip install dataclasses + - name: Install package - shell: bash -l {0} run: | - # python setup.py install python -m pip install --no-deps . python -c "import forcebalance; print(forcebalance.__version__)" + - name: Run tests + run: | + pytest -v --cov=forcebalance --cov-config=setup.cfg --durations=0 --cov-report=xml + - name: Run water study - shell: bash -l {0} run: | cd studies/001_water_tutorial tar xvjf targets.tar.bz2 ForceBalance very_simple.in cd ../../ - - name: Run tests - shell: bash -l {0} - run: | - pytest -v --cov=forcebalance --cov-config=setup.cfg --durations=0 --cov-report=xml - - name: Codecov uses: codecov/codecov-action@v2.1.0 with: diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 0b0bdb7d2..56a169fe0 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -1,13 +1,11 @@ -name: test +name: forcebalance-test channels: - conda-forge - - omnia - - ambermd + - bioconda dependencies: # Base depends - python - pip - # Testing - pytest - pytest-cov @@ -22,9 +20,7 @@ dependencies: - pymbar - openmm - ambertools - # The following two are not compatible with python 2.7 and 3.5, so they are conditionally installed in .travis.yml - #- openforcefield - #- openeye-toolkits - - ndcctools - geometric + - gromacs =2019.1 + - openff-toolkit >=0.10.3|<=0.10.0 diff --git a/src/openmmio.py b/src/openmmio.py index 404631d19..81b80c9d5 100644 --- a/src/openmmio.py +++ b/src/openmmio.py @@ -980,7 +980,18 @@ def update_simulation(self, **kwargs): #printcool_dictionary(self.mmopts, title="Creating/updating simulation in engine %s with system settings:" % (self.name)) # for b in list(self.mod.topology.bonds()): # print b[0].index, b[1].index - self.system = self.forcefield.createSystem(self.mod.topology, **self.mmopts) + try: + self.system = self.forcefield.createSystem(self.mod.topology, **self.mmopts) + # This try/except block catches a failure case introduced by the release of openmm 7.7 + # where a ValueError would be raised if createSystem was given an unused kwarg. + # Now, when that error occurs, we remove the unused kwargs from mmopts. + # More info at https://github.com/leeping/forcebalance/issues/246 + except ValueError as e: + if 'useSwitchingFunction' not in str(e): + raise e + self.mmopts.pop('useSwitchingFunction') + self.mmopts.pop('switchingDistance') + self.system = self.forcefield.createSystem(self.mod.topology, **self.mmopts) self.vsinfo = PrepareVirtualSites(self.system) self.nbcharges = np.zeros(self.system.getNumParticles())