Skip to content

Commit

Permalink
Fix tests (#6)
Browse files Browse the repository at this point in the history
* Update CI.yaml

---------

Co-authored-by: wiederm <[email protected]>
  • Loading branch information
wiederm and wiederm authored Sep 28, 2023
1 parent b7ce1ad commit e26932b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies:
- python
- pip
- openmm>=8.0
- openmm-ml
- openmm-torch
- openff-toolkit
- openmmtools
Expand All @@ -21,9 +20,12 @@ dependencies:
- seaborn
- pytorch #=1.11.0
- loguru
# Testing
- nglview
- fire
# Testing
- pytest
- pytest-cov
- codecov
- black

# Testing
- pytest
Expand All @@ -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
2 changes: 1 addition & 1 deletion guardowl/tests/stability_test_alanine_dipeptide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tests:
env: "solvent"
ensemble: "npt"
nnp: "ani2x"
implementation: "nnpops"
implementation: "torchani"
annealing: false
nr_of_simulation_steps: 100
temperature: 300
2 changes: 1 addition & 1 deletion guardowl/tests/stability_test_hipen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ tests:
- protocol: "hipen_protocol"
hipen_idx: 0
nnp: "ani2x"
implementation: "nnpops"
implementation: "torchani"
temperature: 300
nr_of_simulation_steps: 100
2 changes: 1 addition & 1 deletion guardowl/tests/stability_test_waterbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions guardowl/tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"""

Expand Down
8 changes: 4 additions & 4 deletions guardowl/tests/test_stability_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"""

Expand Down Expand Up @@ -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"""

Expand Down Expand Up @@ -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"""

Expand Down
17 changes: 15 additions & 2 deletions guardowl/utils.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e26932b

Please sign in to comment.