Skip to content

Commit

Permalink
fix: reset only changed paths (workaround to preempt nipy#2968)
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban committed Aug 2, 2019
1 parent 0c7a76e commit cf9ab58
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions nipype/pipeline/engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ def save_resultfile(result, cwd, name, rebase=True):
try:
with indirectory(cwd):
# All the magic to fix #2944 resides here:
for key, val in list(outputs.items()):
val = rebase_path_traits(result.outputs.trait(key), val, cwd)
setattr(result.outputs, key, val)
for key, old in list(outputs.items()):
val = rebase_path_traits(result.outputs.trait(key), old, cwd)
if old != val: # Workaround #2968: Reset only changed values
setattr(result.outputs, key, val)
savepkl(resultsfile, result)
finally:
# Reset resolved paths from the outputs dict no matter what
# Restore resolved paths from the outputs dict no matter what
for key, val in list(outputs.items()):
setattr(result.outputs, key, val)

Expand Down Expand Up @@ -297,17 +298,18 @@ def load_resultfile(results_file, resolve=True):
else:
aggregate = False

if resolve and result.outputs:
try:
outputs = result.outputs.get()
except TypeError: # This is a Bunch
return result, aggregate, attribute_error

logger.debug('Resolving paths in outputs loaded from results file.')
for trait_name, old_value in list(outputs.items()):
value = resolve_path_traits(result.outputs.trait(trait_name), old_value,
results_file.parent)
setattr(result.outputs, trait_name, value)
if resolve and result.outputs:
try:
outputs = result.outputs.get()
except TypeError: # This is a Bunch
return result, aggregate, attribute_error

logger.debug('Resolving paths in outputs loaded from results file.')
for trait_name, old in list(outputs.items()):
value = resolve_path_traits(result.outputs.trait(trait_name), old,
results_file.parent)
if value != old: # Workaround #2968: Reset only changed values
setattr(result.outputs, trait_name, value)

return result, aggregate, attribute_error

Expand Down

0 comments on commit cf9ab58

Please sign in to comment.