Skip to content

Commit 2b782b0

Browse files
committed
enh: read true value from traits
1 parent 3011443 commit 2b782b0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nipype/pipeline/engine/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,21 @@ def save_resultfile(result, cwd, name, rebase=True):
245245
savepkl(resultsfile, result)
246246
return
247247

248+
backup_traits = {}
248249
try:
249250
with indirectory(cwd):
250251
# All the magic to fix #2944 resides here:
251252
for key, old in list(outputs.items()):
252253
if isdefined(old):
254+
old = result.outputs.trait(key).handler.get_value(result.outputs, key)
255+
backup_traits[key] = old
253256
val = rebase_path_traits(result.outputs.trait(key), old, cwd)
254257
setattr(result.outputs, key, val)
255258
savepkl(resultsfile, result)
256259
finally:
257260
# Restore resolved paths from the outputs dict no matter what
258-
for key, val in list(outputs.items()):
259-
if isdefined(val):
260-
setattr(result.outputs, key, val)
261+
for key, val in list(backup_traits.items()):
262+
setattr(result.outputs, key, val)
261263

262264

263265
def load_resultfile(results_file, resolve=True):
@@ -308,6 +310,8 @@ def load_resultfile(results_file, resolve=True):
308310
logger.debug('Resolving paths in outputs loaded from results file.')
309311
for trait_name, old in list(outputs.items()):
310312
if isdefined(old):
313+
old = result.outputs.trait(trait_name).handler.get_value(
314+
result.outputs, trait_name)
311315
value = resolve_path_traits(result.outputs.trait(trait_name), old,
312316
results_file.parent)
313317
setattr(result.outputs, trait_name, value)

0 commit comments

Comments
 (0)