@@ -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