@@ -307,12 +307,13 @@ def save_resultfile(result, cwd, name, rebase=True):
307
307
try :
308
308
with indirectory (cwd ):
309
309
# All the magic to fix #2944 resides here:
310
- for key , val in list (outputs .items ()):
311
- val = rebase_path_traits (result .outputs .trait (key ), val , cwd )
312
- setattr (result .outputs , key , val )
310
+ for key , old in list (outputs .items ()):
311
+ val = rebase_path_traits (result .outputs .trait (key ), old , cwd )
312
+ if old != val : # Workaround #2968: Reset only changed values
313
+ setattr (result .outputs , key , val )
313
314
savepkl (resultsfile , result )
314
315
finally :
315
- # Reset resolved paths from the outputs dict no matter what
316
+ # Restore resolved paths from the outputs dict no matter what
316
317
for key , val in list (outputs .items ()):
317
318
setattr (result .outputs , key , val )
318
319
@@ -362,16 +363,17 @@ def load_resultfile(path, name, resolve=True):
362
363
finally :
363
364
pkl_file .close ()
364
365
365
- if resolve and result .outputs :
366
- try :
367
- outputs = result .outputs .get ()
368
- except TypeError : # This is a Bunch
369
- return result , aggregate , attribute_error
370
-
371
- logger .debug ('Resolving paths in outputs loaded from results file.' )
372
- for trait_name , old_value in list (outputs .items ()):
373
- value = resolve_path_traits (result .outputs .trait (trait_name ), old_value , path )
374
- setattr (result .outputs , trait_name , value )
366
+ if resolve and result .outputs :
367
+ try :
368
+ outputs = result .outputs .get ()
369
+ except TypeError : # This is a Bunch
370
+ return result , aggregate , attribute_error
371
+
372
+ logger .debug ('Resolving paths in outputs loaded from results file.' )
373
+ for trait_name , old in list (outputs .items ()):
374
+ value = resolve_path_traits (result .outputs .trait (trait_name ), old , path )
375
+ if value != old : # Workaround #2968: Reset only changed values
376
+ setattr (result .outputs , trait_name , value )
375
377
376
378
return result , aggregate , attribute_error
377
379
0 commit comments