Skip to content

Commit 11710a7

Browse files
committed
Modify quickrun to allow resuming
1 parent 89d1948 commit 11710a7

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies:
5353
# Control blas/openmp threads
5454
- threadpoolctl
5555
- pip:
56-
- git+https://github.com/OpenFreeEnergy/gufe@main
56+
- git+https://github.com/OpenFreeEnergy/gufe@restart_execute
5757
- run_constrained:
5858
# drop this pin when handled upstream in espaloma-feedstock
5959
- smirnoff99frosst>=1.1.0.1 #https://github.com/openforcefield/smirnoff99Frosst/issues/109

src/openfecli/commands/quickrun.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ def quickrun(transformation, work_dir, output):
4949
for each repeat of the sampling process (by default 3).
5050
"""
5151
import logging
52+
from json import JSONDecodeError
5253
import os
5354
import sys
5455

56+
from gufe import ProtocolDAG
5557
from gufe.protocols.protocoldag import execute_DAG
5658
from gufe.tokenization import JSON_HANDLER
5759
from gufe.transformations.transformation import Transformation
@@ -94,13 +96,26 @@ def quickrun(transformation, work_dir, output):
9496
else:
9597
output.parent.mkdir(exist_ok=True, parents=True)
9698

97-
write("Planning simulations for this edge...")
98-
dag = trans.create()
99+
# Attempt to either deserialize or freshly create DAG
100+
if (work_dir / "protocol_dag.json").is_file():
101+
write("Attempting to recover edge simulations from file")
102+
try:
103+
dag = ProtocolDAG.from_json(work_dir / "protocol_dag.json")
104+
except JSONDecodeError:
105+
errmsg = "Recovery failed, please clean workdir before continuing"
106+
raise click.ClickException(errmsg)
107+
else:
108+
# Create the DAG instead and then serialize for later resuming
109+
write("Planning simulations for this edge...")
110+
dag = trans.create()
111+
dag.to_json(work_dir / "protocol_dag.json")
112+
99113
write("Starting the simulations for this edge...")
100114
dagresult = execute_DAG(
101115
dag,
102116
shared_basedir=work_dir,
103117
scratch_basedir=work_dir,
118+
unitresults_basedir=work_dir,
104119
keep_shared=True,
105120
raise_error=False,
106121
n_retries=2,

0 commit comments

Comments
 (0)