Skip to content

Commit 682c73c

Browse files
committed
fix: reset only changed paths (workaround to preempt #2968)
1 parent cba8080 commit 682c73c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

nipype/pipeline/engine/utils.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,13 @@ def save_resultfile(result, cwd, name, rebase=True):
307307
try:
308308
with indirectory(cwd):
309309
# 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)
313314
savepkl(resultsfile, result)
314315
finally:
315-
# Reset resolved paths from the outputs dict no matter what
316+
# Restore resolved paths from the outputs dict no matter what
316317
for key, val in list(outputs.items()):
317318
setattr(result.outputs, key, val)
318319

@@ -362,16 +363,17 @@ def load_resultfile(path, name, resolve=True):
362363
finally:
363364
pkl_file.close()
364365

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)
375377

376378
return result, aggregate, attribute_error
377379

0 commit comments

Comments
 (0)