Skip to content

Commit ece8f08

Browse files
committed
fix: reset only changed paths (workaround to preempt #2968)
1 parent c87f952 commit ece8f08

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

nipype/pipeline/engine/utils.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,13 @@ def save_resultfile(result, cwd, name, rebase=True):
248248
try:
249249
with indirectory(cwd):
250250
# All the magic to fix #2944 resides here:
251-
for key, val in list(outputs.items()):
252-
val = rebase_path_traits(result.outputs.trait(key), val, cwd)
253-
setattr(result.outputs, key, val)
251+
for key, old in list(outputs.items()):
252+
val = rebase_path_traits(result.outputs.trait(key), old, cwd)
253+
if old != val: # Workaround #2968: Reset only changed values
254+
setattr(result.outputs, key, val)
254255
savepkl(resultsfile, result)
255256
finally:
256-
# Reset resolved paths from the outputs dict no matter what
257+
# Restore resolved paths from the outputs dict no matter what
257258
for key, val in list(outputs.items()):
258259
setattr(result.outputs, key, val)
259260

@@ -297,17 +298,18 @@ def load_resultfile(results_file, resolve=True):
297298
else:
298299
aggregate = False
299300

300-
if resolve and result.outputs:
301-
try:
302-
outputs = result.outputs.get()
303-
except TypeError: # This is a Bunch
304-
return result, aggregate, attribute_error
305-
306-
logger.debug('Resolving paths in outputs loaded from results file.')
307-
for trait_name, old_value in list(outputs.items()):
308-
value = resolve_path_traits(result.outputs.trait(trait_name), old_value,
309-
results_file.parent)
310-
setattr(result.outputs, trait_name, value)
301+
if resolve and result.outputs:
302+
try:
303+
outputs = result.outputs.get()
304+
except TypeError: # This is a Bunch
305+
return result, aggregate, attribute_error
306+
307+
logger.debug('Resolving paths in outputs loaded from results file.')
308+
for trait_name, old in list(outputs.items()):
309+
value = resolve_path_traits(result.outputs.trait(trait_name), old,
310+
results_file.parent)
311+
if value != old: # Workaround #2968: Reset only changed values
312+
setattr(result.outputs, trait_name, value)
311313

312314
return result, aggregate, attribute_error
313315

0 commit comments

Comments
 (0)