@@ -433,15 +433,15 @@ def _run(self, rerun=False, **kwargs):
433
433
lockfile = self .cache_dir / (checksum + ".lock" )
434
434
# Eagerly retrieve cached - see scenarios in __init__()
435
435
self .hooks .pre_run (self )
436
- # adding info file with the checksum in case the task was cancelled
437
- # and the lockfile has to be removed
438
- with open (self .cache_dir / f"{ self .uid } _info.json" , "w" ) as jsonfile :
439
- json .dump ({"checksum" : self .checksum }, jsonfile )
440
436
with SoftFileLock (lockfile ):
441
437
if not (rerun or self .task_rerun ):
442
438
result = self .result ()
443
439
if result is not None :
444
440
return result
441
+ # adding info file with the checksum in case the task was cancelled
442
+ # and the lockfile has to be removed
443
+ with open (self .cache_dir / f"{ self .uid } _info.json" , "w" ) as jsonfile :
444
+ json .dump ({"checksum" : self .checksum }, jsonfile )
445
445
# Let only one equivalent process run
446
446
odir = self .output_dir
447
447
if not self .can_resume and odir .exists ():
@@ -965,11 +965,6 @@ async def _run(self, submitter=None, rerun=False, **kwargs):
965
965
"Workflow output cannot be None, use set_output to define output(s)"
966
966
)
967
967
checksum = self .checksum
968
- # Eagerly retrieve cached
969
- if not (rerun or self .task_rerun ):
970
- result = self .result ()
971
- if result is not None :
972
- return result
973
968
# creating connections that were defined after adding tasks to the wf
974
969
for task in self .graph .nodes :
975
970
# if workflow has task_rerun=True and propagate_rerun=True,
@@ -981,15 +976,18 @@ async def _run(self, submitter=None, rerun=False, **kwargs):
981
976
task .propagate_rerun = self .propagate_rerun
982
977
task .cache_locations = task ._cache_locations + self .cache_locations
983
978
self .create_connections (task )
984
- # TODO add signal handler for processes killed after lock acquisition
985
- # adding info file with the checksum in case the task was cancelled
986
- # and the lockfile has to be removed
987
- with open (self .cache_dir / f"{ self .uid } _info.json" , "w" ) as jsonfile :
988
- json .dump ({"checksum" : checksum }, jsonfile )
989
979
lockfile = self .cache_dir / (checksum + ".lock" )
990
980
self .hooks .pre_run (self )
991
981
with SoftFileLock (lockfile ):
992
- # # Let only one equivalent process run
982
+ # retrieve cached results
983
+ if not (rerun or self .task_rerun ):
984
+ result = self .result ()
985
+ if result is not None :
986
+ return result
987
+ # adding info file with the checksum in case the task was cancelled
988
+ # and the lockfile has to be removed
989
+ with open (self .cache_dir / f"{ self .uid } _info.json" , "w" ) as jsonfile :
990
+ json .dump ({"checksum" : checksum }, jsonfile )
993
991
odir = self .output_dir
994
992
if not self .can_resume and odir .exists ():
995
993
shutil .rmtree (odir )
@@ -1015,6 +1013,8 @@ async def _run(self, submitter=None, rerun=False, **kwargs):
1015
1013
(self .cache_dir / f"{ self .uid } _info.json" ).unlink ()
1016
1014
os .chdir (cwd )
1017
1015
self .hooks .post_run (self , result )
1016
+ if result is None :
1017
+ raise Exception ("This should never happen, please open new issue" )
1018
1018
return result
1019
1019
1020
1020
async def _run_task (self , submitter , rerun = False ):
0 commit comments