32
32
to_str ,
33
33
ensure_list ,
34
34
get_related_files ,
35
- FileNotFoundError ,
36
35
save_json ,
37
36
savepkl ,
38
37
write_rst_header ,
41
40
)
42
41
from ...utils .misc import str2bool
43
42
from ...utils .functions import create_function_from_source
44
- from ...interfaces .base .traits_extension import rebase_path_traits , resolve_path_traits
45
- from ...interfaces .base import (Bunch , CommandLine , isdefined , Undefined ,
46
- InterfaceResult , traits )
43
+ from ...interfaces .base .traits_extension import (
44
+ rebase_path_traits , resolve_path_traits , OutputMultiPath , isdefined , Undefined , traits )
45
+ from ...interfaces .base .support import Bunch , InterfaceResult
46
+ from ...interfaces .base import CommandLine
47
47
from ...interfaces .utility import IdentityInterface
48
48
from ...utils .provenance import ProvStore , pm , nipype_ns , get_id
49
49
@@ -240,7 +240,7 @@ def save_resultfile(result, cwd, name, rebase=True):
240
240
return
241
241
242
242
try :
243
- outputs = result .outputs .trait_get ()
243
+ output_names = result .outputs .copyable_trait_names ()
244
244
except AttributeError :
245
245
logger .debug ('Storing non-traited results, skipping rebase of paths' )
246
246
savepkl (resultsfile , result )
@@ -250,9 +250,12 @@ def save_resultfile(result, cwd, name, rebase=True):
250
250
try :
251
251
with indirectory (cwd ):
252
252
# All the magic to fix #2944 resides here:
253
- for key , old in list (outputs .items ()):
253
+ for key in output_names :
254
+ old = getattr (result .outputs , key )
254
255
if isdefined (old ):
255
- old = result .outputs .trait (key ).handler .get_value (result .outputs , key )
256
+ if result .outputs .trait (key ).is_trait_type (OutputMultiPath ):
257
+ old = result .outputs .trait (key ).handler .get_value (
258
+ result .outputs , key )
256
259
backup_traits [key ] = old
257
260
val = rebase_path_traits (result .outputs .trait (key ), old , cwd )
258
261
setattr (result .outputs , key , val )
@@ -317,8 +320,9 @@ def load_resultfile(path, name, resolve=True):
317
320
logger .debug ('Resolving paths in outputs loaded from results file.' )
318
321
for trait_name , old in list (outputs .items ()):
319
322
if isdefined (old ):
320
- old = result .outputs .trait (trait_name ).handler .get_value (
321
- result .outputs , trait_name )
323
+ if result .outputs .trait (trait_name ).is_trait_type (OutputMultiPath ):
324
+ old = result .outputs .trait (trait_name ).handler .get_value (
325
+ result .outputs , trait_name )
322
326
value = resolve_path_traits (result .outputs .trait (trait_name ), old , path )
323
327
setattr (result .outputs , trait_name , value )
324
328
0 commit comments