Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests and more robust netcdf opening #1168

Merged
merged 4 commits into from
May 31, 2019
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
6 changes: 6 additions & 0 deletions Yank/multistate/multistatereporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ def _open_dataset_robustly(self, *args, n_attempts=5, sleep_time=2,
logger.debug('Attempt {}/{} to open {} failed. Retrying '
'in {} seconds'.format(i+1, n_attempts, sleep_time))
time.sleep(sleep_time)

# At the very last attempt, we try setting the environment variable
# controlling the locking mechanism of HDF5 (see choderalab/yank#1165).
if n_attempts > 1:
os.environ['HDF5_USE_FILE_LOCKING'] = 'FALSE'

# Last attempt finally raises any error.
return netcdf.Dataset(*args, **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions Yank/multistate/replicaexchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ def _mix_replicas(self):
# otherwise fall back to Python-accelerated code.
try:
self._mix_all_replicas_cython()
except ValueError as e:
logger.warning(e.message)
except (ValueError, ImportError) as e:
logger.warning(str(e))
self._mix_all_replicas()
else:
assert self.replica_mixing_scheme is None
Expand Down
18 changes: 9 additions & 9 deletions Yank/tests/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def test_validation_correct_systems():


def test_validation_wrong_systems():
"""YAML validation raises exception with wrong experiments specification."""
"""YAML validation raises exception with wrong systems specification."""
data_paths = examples_paths()
exp_builder = ExperimentBuilder()
basic_script = """
Expand All @@ -779,10 +779,10 @@ def test_validation_wrong_systems():
("regions\(s\) clashing",
{'receptor': 'rec_region', 'ligand': 'lig_region', 'solvent': 'solv'}),

("ligand: \[must be of string type\]",
("ligand:\n- must be of string type",
{'receptor': 'rec', 'ligand': 1, 'solvent': 'solv'}),

("solvent: \[must be of string type\]",
("solvent:\n- must be of string type",
{'receptor': 'rec', 'ligand': 'lig', 'solvent': ['solv', 'solv']}),

("unallowed value unknown",
Expand All @@ -792,11 +792,11 @@ def test_validation_wrong_systems():
{'receptor': 'rec', 'ligand': 'lig', 'solvent': 'solv4',
'leap': {'parameters': ['leaprc.gaff', 'leaprc.ff14SB']}}),

("parameters: \[unknown field\]",
("parameters:\n- unknown field",
{'receptor': 'rec', 'ligand': 'lig', 'solvent': 'solv3',
'parameters': 'leaprc.ff14SB'}),

("phase1_path: \[must be of list type\]",
("phase1_path:\n- must be of list type",
{'phase1_path': data_paths['bentol-complex'][0],
'phase2_path': data_paths['bentol-solvent'],
'ligand_dsl': 'resname BEN', 'solvent': 'solv'}),
Expand All @@ -806,7 +806,7 @@ def test_validation_wrong_systems():
'phase2_path': data_paths['bentol-solvent'],
'ligand_dsl': 'resname BEN', 'solvent': 'solv'}),

("ligand_dsl: \[must be of string type\]",
("ligand_dsl:\n- must be of string type",
{'phase1_path': data_paths['bentol-complex'],
'phase2_path': data_paths['bentol-solvent'],
'ligand_dsl': 3.4, 'solvent': 'solv'}),
Expand All @@ -828,7 +828,7 @@ def test_validation_wrong_systems():
("''ligand'' must not be present with ''solute''",
{'ligand': 'lig', 'solute': 'lig', 'solvent1': 'solv', 'solvent2': 'solv'}),

("leap: \[must be of dict type\]",
("leap:\n- must be of dict type",
{'solute': 'lig', 'solvent1': 'solv', 'solvent2': 'solv', 'leap': 'leaprc.gaff'})
]
for regexp, system in systems:
Expand All @@ -852,10 +852,10 @@ def test_validation_correct_mcmc_moves():


def test_validation_wrong_mcmc_moves():
"""YAML validation raises exception with wrong experiments specification."""
"""YAML validation raises exception with wrong mcmc move specification."""
# Each test case is a pair (regexp_error, mcmc_move_description).
mcmc_moves = [
("The expression 2.0 must be\s+ a string",
("The expression 2.0 must be a string",
{'type': 'LangevinSplittingDynamicsMove', 'timestep': 2.0}),
("Could not find class UnknownMoveClass",
{'type': 'UnknownMoveClass'}),
Expand Down
8 changes: 8 additions & 0 deletions docs/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ This section features and improvements of note in each release.

The full release history can be viewed `at the GitHub yank releases page <https://github.com/choderalab/yank/releases>`_.

0.24.1 Bugfix release
---------------------

Bugfixes
^^^^^^^^
- Improve the robustness of opening the netcdf file on resuming of the multi-state samplers by setting the environment variable ``HDF5_USE_FILE_LOCKING`` to ``'FALSE'`` after 4 failed attempts (`#1168 <https://github.com/choderalab/yank/pull/1168>`_).
- Fixed a bug causing a crash during exception handling (`#1168 <https://github.com/choderalab/yank/pull/1168>`_).

0.24.0 Experimental support for online status files
---------------------------------------------------

Expand Down