Skip to content

Commit 1e59d57

Browse files
committed
enh: read true value from traits
1 parent 9dcce52 commit 1e59d57

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nipype/pipeline/engine/utils.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,21 @@ def save_resultfile(result, cwd, name, rebase=True):
246246
savepkl(resultsfile, result)
247247
return
248248

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

263265

264266
def load_resultfile(path, name, resolve=True):
@@ -315,6 +317,8 @@ def load_resultfile(path, name, resolve=True):
315317
logger.debug('Resolving paths in outputs loaded from results file.')
316318
for trait_name, old in list(outputs.items()):
317319
if isdefined(old):
320+
old = result.outputs.trait(trait_name).handler.get_value(
321+
result.outputs, trait_name)
318322
value = resolve_path_traits(result.outputs.trait(trait_name), old, path)
319323
setattr(result.outputs, trait_name, value)
320324

0 commit comments

Comments
 (0)