Skip to content

Commit 85fdcc7

Browse files
committed
fix: reset only changed paths (workaround to preempt nipy#2968)
1 parent 35cc7b5 commit 85fdcc7

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

nipype/pipeline/engine/utils.py

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

@@ -304,16 +305,17 @@ def load_resultfile(path, name, resolve=True):
304305
finally:
305306
pkl_file.close()
306307

307-
if resolve and result.outputs:
308-
try:
309-
outputs = result.outputs.get()
310-
except TypeError: # This is a Bunch
311-
return result, aggregate, attribute_error
312-
313-
logger.debug('Resolving paths in outputs loaded from results file.')
314-
for trait_name, old_value in list(outputs.items()):
315-
value = resolve_path_traits(result.outputs.trait(trait_name), old_value, path)
316-
setattr(result.outputs, trait_name, value)
308+
if resolve and result.outputs:
309+
try:
310+
outputs = result.outputs.get()
311+
except TypeError: # This is a Bunch
312+
return result, aggregate, attribute_error
313+
314+
logger.debug('Resolving paths in outputs loaded from results file.')
315+
for trait_name, old in list(outputs.items()):
316+
value = resolve_path_traits(result.outputs.trait(trait_name), old, path)
317+
if value != old: # Workaround #2968: Reset only changed values
318+
setattr(result.outputs, trait_name, value)
317319

318320
return result, aggregate, attribute_error
319321

0 commit comments

Comments
 (0)