Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions openfe/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from rdkit import Chem
from rdkit.Chem import AllChem
from openff.units import unit
import urllib.request

import gufe
import openfe
Expand Down Expand Up @@ -304,3 +305,10 @@ def am1bcc_ref_charges():
] * unit.elementary_charge,
}
return ref_chgs

try:
urllib.request.urlopen('https://www.google.com')
except: # -no-cov-
HAS_INTERNET = False
else:
HAS_INTERNET = True
19 changes: 0 additions & 19 deletions openfe/tests/protocols/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from rdkit.Geometry import Point3D
import openfe
from openff.units import unit
import pooch


@pytest.fixture
Expand Down Expand Up @@ -232,21 +231,3 @@ def md_json() -> str:

with gzip.open((d / fname).as_posix(), 'r') as f: # type: ignore
return f.read().decode() # type: ignore


RFE_OUTPUT = pooch.create(
path=pooch.os_cache("openfe_analysis"),
base_url="doi:10.6084/m9.figshare.24101655",
registry={
"checkpoint.nc": "5af398cb14340fddf7492114998b244424b6c3f4514b2e07e4bd411484c08464",
"db.json": "b671f9eb4daf9853f3e1645f9fd7c18150fd2a9bf17c18f23c5cf0c9fd5ca5b3",
"hybrid_system.pdb": "07203679cb14b840b36e4320484df2360f45e323faadb02d6eacac244fddd517",
"simulation.nc": "92361a0864d4359a75399470135f56642b72c605069a4c33dbc4be6f91f28b31",
"simulation_real_time_analysis.yaml": "65706002f371fafba96037f29b054fd7e050e442915205df88567f48f5e5e1cf",
}
)


@pytest.fixture
def simulation_nc():
return RFE_OUTPUT.fetch("simulation.nc")
71 changes: 45 additions & 26 deletions openfe/tests/protocols/test_openmmutils.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
# This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
from importlib import resources
import copy
from pathlib import Path
import pytest
import os
import sys
from pymbar.utils import ParameterError
from importlib import resources
from pathlib import Path
from unittest import mock

import numpy as np
from numpy.testing import assert_equal, assert_allclose
from openmm import app, MonteCarloBarostat, NonbondedForce
from openmm import unit as ommunit
from openmmtools import multistate
import openfe
import pooch
import pytest
from gufe.settings import OpenMMSystemGeneratorFFSettings, ThermoSettings
from numpy.testing import assert_allclose, assert_equal
from openfe.protocols.openmm_rfe.equil_rfe_settings import (
IntegratorSettings, OpenMMSolvationSettings)
from openfe.protocols.openmm_utils import (charge_generation,
multistate_analysis, omm_settings,
settings_validation,
system_creation, system_validation)
from openfe.protocols.openmm_utils.charge_generation import (HAS_ESPALOMA,
HAS_NAGL,
HAS_OPENEYE)
Comment on lines +11 to +24
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just me applying isort to this file bc there were many imports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

from openff.toolkit import Molecule as OFFMol
from openff.toolkit.utils.toolkits import RDKitToolkitWrapper
from openff.toolkit.utils.toolkit_registry import ToolkitRegistry
from openff.toolkit.utils.toolkits import RDKitToolkitWrapper
from openff.units import unit
from openff.units.openmm import ensure_quantity, from_openmm
from gufe.settings import OpenMMSystemGeneratorFFSettings, ThermoSettings
import openfe
from openfe.protocols.openmm_utils import (
settings_validation, system_validation, system_creation,
multistate_analysis, omm_settings, charge_generation
)
from openfe.protocols.openmm_utils.charge_generation import (
HAS_NAGL, HAS_ESPALOMA, HAS_OPENEYE
)
from openfe.protocols.openmm_rfe.equil_rfe_settings import (
IntegratorSettings,
OpenMMSolvationSettings,
)
from unittest import mock
from openmm import MonteCarloBarostat, NonbondedForce, app
from openmm import unit as ommunit
from openmmtools import multistate
from pymbar.utils import ParameterError

from ..conftest import HAS_INTERNET


@pytest.mark.parametrize('padding, number_solv, box_vectors, box_size', [
Expand Down Expand Up @@ -928,10 +931,26 @@
)


POOCH_CACHE = pooch.os_cache('openfe')
RFE_OUTPUT = pooch.create(
path=POOCH_CACHE,
base_url="doi:10.6084/m9.figshare.24101655",
registry={
"checkpoint.nc": "5af398cb14340fddf7492114998b244424b6c3f4514b2e07e4bd411484c08464",
"db.json": "b671f9eb4daf9853f3e1645f9fd7c18150fd2a9bf17c18f23c5cf0c9fd5ca5b3",
"hybrid_system.pdb": "07203679cb14b840b36e4320484df2360f45e323faadb02d6eacac244fddd517",
"simulation.nc": "92361a0864d4359a75399470135f56642b72c605069a4c33dbc4be6f91f28b31",
"simulation_real_time_analysis.yaml": "65706002f371fafba96037f29b054fd7e050e442915205df88567f48f5e5e1cf",
},
retry_if_failed=3,
)

@pytest.fixture
def simulation_nc():
return RFE_OUTPUT.fetch("simulation.nc")

Check warning on line 950 in openfe/tests/protocols/test_openmmutils.py

View check run for this annotation

Codecov / codecov/patch

openfe/tests/protocols/test_openmmutils.py#L950

Added line #L950 was not covered by tests

@pytest.mark.slow
@pytest.mark.download
# Sometimes we get a DOI lookup error from duecredit
#@pytest.mark.flaky(reruns=3, only_rerun=ValueError, reruns_delay=10)
@pytest.mark.skipif(not os.path.exists(POOCH_CACHE) and not HAS_INTERNET,reason="Internet seems to be unavailable and test data is not cached locally.")
def test_forward_backwards_failure(simulation_nc):
rep = multistate.multistatereporter.MultiStateReporter(
simulation_nc,
Expand Down
1 change: 1 addition & 0 deletions openfecli/tests/commands/test_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def test_skip_all_failed_runs(self, capsys, valid_result):
registry={
"rbfe_results_serial_repeats.tar.gz": "md5:2355ecc80e03242a4c7fcbf20cb45487",
"rbfe_results_parallel_repeats.tar.gz": "md5:ff7313e14eb6f2940c6ffd50f2192181"},
retry_if_failed=3,
)

@pytest.fixture
Expand Down