From e26932b55a53647fc12ca1ac1618a0cbb4b5152a Mon Sep 17 00:00:00 2001 From: Marcus Wieder <31651017+wiederm@users.noreply.github.com> Date: Thu, 28 Sep 2023 22:57:52 +0200 Subject: [PATCH] Fix tests (#6) * Update CI.yaml --------- Co-authored-by: wiederm --- .github/workflows/CI.yaml | 6 +++--- devtools/conda-envs/test_env.yaml | 13 ++++++++----- .../tests/stability_test_alanine_dipeptide.yaml | 2 +- guardowl/tests/stability_test_hipen.yaml | 2 +- guardowl/tests/stability_test_waterbox.yaml | 2 +- guardowl/tests/test_simulation.py | 6 +++--- guardowl/tests/test_stability_protocol.py | 8 ++++---- guardowl/utils.py | 17 +++++++++++++++-- 8 files changed, 36 insertions(+), 20 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 6723564..bdeea51 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -36,12 +36,12 @@ jobs: # More info on options: https://github.com/marketplace/actions/provision-with-micromamba - uses: mamba-org/provision-with-micromamba@main + env: + CONDA_OVERRIDE_CUDA: "11.4" with: + python-version: ${{ matrix.python-version }} environment-file: devtools/conda-envs/test_env.yaml - environment-name: test channels: conda-forge,defaults - extra-specs: | - python=${{ matrix.python-version }} - name: Install package # conda setup requires this special shell diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 4bd9d93..8088402 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -8,7 +8,6 @@ dependencies: - python - pip - openmm>=8.0 - - openmm-ml - openmm-torch - openff-toolkit - openmmtools @@ -21,9 +20,12 @@ dependencies: - seaborn - pytorch #=1.11.0 - loguru - # Testing - nglview - - fire + # Testing + - pytest + - pytest-cov + - codecov + - black # Testing - pytest @@ -32,5 +34,6 @@ dependencies: # Pip-only installs - pip: - - nvidia-ml-py3 - - nptyping + - nvidia-ml-py3 + - nptyping + - git+https://github.com/openmm/openmm-ml.git diff --git a/guardowl/tests/stability_test_alanine_dipeptide.yaml b/guardowl/tests/stability_test_alanine_dipeptide.yaml index a9bc8c7..55d2f74 100644 --- a/guardowl/tests/stability_test_alanine_dipeptide.yaml +++ b/guardowl/tests/stability_test_alanine_dipeptide.yaml @@ -4,7 +4,7 @@ tests: env: "solvent" ensemble: "npt" nnp: "ani2x" - implementation: "nnpops" + implementation: "torchani" annealing: false nr_of_simulation_steps: 100 temperature: 300 diff --git a/guardowl/tests/stability_test_hipen.yaml b/guardowl/tests/stability_test_hipen.yaml index ef48ac5..405cf20 100644 --- a/guardowl/tests/stability_test_hipen.yaml +++ b/guardowl/tests/stability_test_hipen.yaml @@ -3,6 +3,6 @@ tests: - protocol: "hipen_protocol" hipen_idx: 0 nnp: "ani2x" - implementation: "nnpops" + implementation: "torchani" temperature: 300 nr_of_simulation_steps: 100 diff --git a/guardowl/tests/stability_test_waterbox.yaml b/guardowl/tests/stability_test_waterbox.yaml index bc9fa7a..d7eea93 100644 --- a/guardowl/tests/stability_test_waterbox.yaml +++ b/guardowl/tests/stability_test_waterbox.yaml @@ -4,7 +4,7 @@ tests: edge_length: 10 ensemble: "npt" nnp: "ani2x" - implementation: "nnpops" + implementation: "torchani" annealing: false nr_of_simulation_steps: 100 temperature: 300 diff --git a/guardowl/tests/test_simulation.py b/guardowl/tests/test_simulation.py index 5cfe350..bf4799f 100644 --- a/guardowl/tests/test_simulation.py +++ b/guardowl/tests/test_simulation.py @@ -9,6 +9,7 @@ from guardowl.setup import create_system_from_mol, generate_molecule from guardowl.simulation import SimulationFactory, SystemFactory from guardowl.testsystems import hipen_systems +from guardowl.utils import get_available_nnps_and_implementation @pytest.mark.parametrize( @@ -69,9 +70,8 @@ def test_generate_simulation_instance( with open("initial_frame_lamb_1.0.pdb", "w") as f: PDBFile.writeFile(topology, pos, f) -@pytest.mark.parametrize( - "nnp, implementation", [("ani2x", "nnpops"), ("ani2x", "torchani"), ("ani2x", "")] -) + +@pytest.mark.parametrize("nnp, implementation", get_available_nnps_and_implementation()) def test_simulating(nnp: str, implementation: str) -> None: """Test if we can run a simulation for a number of steps""" diff --git a/guardowl/tests/test_stability_protocol.py b/guardowl/tests/test_stability_protocol.py index 9b8cfe7..500fb4d 100644 --- a/guardowl/tests/test_stability_protocol.py +++ b/guardowl/tests/test_stability_protocol.py @@ -6,7 +6,6 @@ from openmmml import MLPotential from openmmtools.utils import get_fastest_platform -from guardowl.utils import available_nnps_and_implementation from guardowl.protocols import ( BondProfileProtocol, DOFTestParameters, @@ -20,9 +19,10 @@ SmallMoleculeTestsystemFactory, WaterboxTestsystemFactory, ) +from guardowl.utils import get_available_nnps_and_implementation -@pytest.mark.parametrize("nnp, implementation", available_nnps_and_implementation) +@pytest.mark.parametrize("nnp, implementation", get_available_nnps_and_implementation()) def test_setup_vacuum_protocol(nnp: str, implementation: str) -> None: """Test if we can run a simulation for a number of steps""" @@ -71,7 +71,7 @@ def test_setup_vacuum_protocol(nnp: str, implementation: str) -> None: @pytest.mark.parametrize("ensemble", ["NVE", "NVT", "NpT"]) -@pytest.mark.parametrize("nnp, implementation", available_nnps_and_implementation) +@pytest.mark.parametrize("nnp, implementation", get_available_nnps_and_implementation()) def test_setup_waterbox_protocol(ensemble: str, nnp: str, implementation: str) -> None: """Test if we can run a simulation for a number of steps""" @@ -126,7 +126,7 @@ def test_setup_waterbox_protocol(ensemble: str, nnp: str, implementation: str) - ) -@pytest.mark.parametrize("nnp, implementation", available_nnps_and_implementation) +@pytest.mark.parametrize("nnp, implementation", get_available_nnps_and_implementation()) def test_DOF_protocol(nnp: str, implementation: str) -> None: """Test if we can run a simulation for a number of steps""" diff --git a/guardowl/utils.py b/guardowl/utils.py index 8c3ce7d..0782a86 100644 --- a/guardowl/utils.py +++ b/guardowl/utils.py @@ -1,6 +1,19 @@ +import os + available_nnps_and_implementation = [ ("ani2x", "nnpops"), ("ani2x", "torchani"), - ("ani1ccx", "nnpops"), - ("ani1ccx", "torchani"), ] + +gh_available_nnps_and_implementation = [ + ("ani2x", "torchani"), +] + + +def get_available_nnps_and_implementation() -> list: + """Return a list of available neural network potentials and implementations""" + IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" + if IN_GITHUB_ACTIONS: + return gh_available_nnps_and_implementation + else: + return available_nnps_and_implementation