Skip to content

Commit

Permalink
Merge pull request #1178 from choderalab/fix-917-setup-only
Browse files Browse the repository at this point in the history
Fix #917: CLI command to setup simulations only
  • Loading branch information
andrrizzi authored Jul 31, 2019
2 parents c18f5a9 + 5055542 commit 61cf64c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
11 changes: 9 additions & 2 deletions Yank/commands/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
YANK script
Usage:
yank script (-y FILEPATH | --yaml=FILEPATH) [--jobid=INTEGER] [--njobs=INTEGER] [-o OVERRIDE] [--status] ...
yank script (-y FILEPATH | --yaml=FILEPATH) [--setup-only] [--jobid=INTEGER] [--njobs=INTEGER] [-o OVERRIDE] [--status] ...
Description:
Set up and run free energy calculations from a YAML script. All options can be specified in the YAML script.
Expand All @@ -32,6 +32,8 @@
-y, --yaml=FILEPATH Path to the YAML script specifying options and/or how to set up and run the experiment.
Optional Arguments:
--setup-only If given, only the automatic setup pipeline is run without running the free energy
calculation.
--jobid=INTEGER You can run only a subset of the experiments by specifying jobid and njobs, where
1 <= job_id <= n_jobs. In this case, njobs must be specified as well and YANK will
run only 1/n_jobs of the experiments. This can be used to run several separate YANK
Expand Down Expand Up @@ -145,7 +147,12 @@ def dispatch(args):
yaml_builder = ExperimentBuilder(script=yaml_path, job_id=job_id, n_jobs=n_jobs)
if override: # Parse the string present.
yaml_builder.update_yaml(override)
yaml_builder.run_experiments(write_status=write_status)

# Check if we need to run only the automatic setup pipeline or also the experiments.
if args['--setup-only']:
yaml_builder.setup_experiments()
else:
yaml_builder.run_experiments(write_status=write_status)
return True

return False
14 changes: 8 additions & 6 deletions Yank/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2031,16 +2031,18 @@ def ensure_restraint_type_is_key(field, restraints_dict, error):
# if we run multiple experiments in parallel, we won't have
# multiple processes running the same one.
try:
if isinstance(yaml_content['experiments'], list):
combinatorial_trees = [(exp_name, utils.CombinatorialTree(yaml_content[exp_name]))
for exp_name in yaml_content['experiments']]
else:
combinatorial_trees = [('experiments', utils.CombinatorialTree(yaml_content['experiments']))]
self._experiments = collections.OrderedDict(combinatorial_trees)
experiments_section = yaml_content['experiments']
except KeyError:
self._experiments = collections.OrderedDict()
return

if isinstance(experiments_section, list):
combinatorial_trees = [(exp_name, utils.CombinatorialTree(yaml_content[exp_name]))
for exp_name in experiments_section]
else:
combinatorial_trees = [('experiments', utils.CombinatorialTree(experiments_section))]
self._experiments = collections.OrderedDict(combinatorial_trees)

# Experiments Schema
experiment_schema_yaml = """
system:
Expand Down
11 changes: 10 additions & 1 deletion docs/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ API-breaking changes

New features
^^^^^^^^^^^^
- The trailblaze algorithm used for the authomatic generation of the alchemical path is now capable of resuming after an unexpected interruption or crash. The samples generated during the process are used to initialize the replicas of the replica exchange or SAMS free energy calculation (`#1176 <https://github.com/choderalab/yank/pull/1176>`_).
- The trailblaze algorithm used for the authomatic generation of the alchemical path is now capable of resuming after an
unexpected interruption or crash. The samples generated during the process are used to initialize the replicas of the
replica exchange or SAMS free energy calculation (`#1176 <https://github.com/choderalab/yank/pull/1176>`_).
- Added a ``--setup-only`` flag in the ``yank script`` CLI command to run the automatic setup pipeline without running
the free energy calculation (`#1178 <https://github.com/choderalab/yank/pull/1178>`_).

Bugfixes
^^^^^^^^
- Fix a bug in which a list of ``experiments: [exp1, exp2]`` in the YAML file containing an unkown experiment name would
fail silently without error (`#1178 <https://github.com/choderalab/yank/pull/1178>`_).

Enhancements
^^^^^^^^^^^^
Expand Down

0 comments on commit 61cf64c

Please sign in to comment.