4141)
4242from ...utils .misc import str2bool
4343from ...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 )
44+ from ...interfaces .base .traits_extension import (
45+ rebase_path_traits , resolve_path_traits , OutputMultiPath , isdefined , Undefined , traits )
46+ from ...interfaces .base .support import Bunch , InterfaceResult
47+ from ...interfaces .base import CommandLine
4748from ...interfaces .utility import IdentityInterface
4849from ...utils .provenance import ProvStore , pm , nipype_ns , get_id
4950
@@ -239,7 +240,7 @@ def save_resultfile(result, cwd, name, rebase=True):
239240 savepkl (resultsfile , result )
240241 return
241242 try :
242- outputs = result .outputs .trait_get ()
243+ output_names = result .outputs .copyable_trait_names ()
243244 except AttributeError :
244245 logger .debug ('Storing non-traited results, skipping rebase of paths' )
245246 savepkl (resultsfile , result )
@@ -249,9 +250,12 @@ def save_resultfile(result, cwd, name, rebase=True):
249250 try :
250251 with indirectory (cwd ):
251252 # All the magic to fix #2944 resides here:
252- for key , old in list (outputs .items ()):
253+ for key in output_names :
254+ old = getattr (result .outputs , key )
253255 if isdefined (old ):
254- 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 )
255259 backup_traits [key ] = old
256260 val = rebase_path_traits (result .outputs .trait (key ), old , cwd )
257261 setattr (result .outputs , key , val )
@@ -310,8 +314,9 @@ def load_resultfile(results_file, resolve=True):
310314 logger .debug ('Resolving paths in outputs loaded from results file.' )
311315 for trait_name , old in list (outputs .items ()):
312316 if isdefined (old ):
313- old = result .outputs .trait (trait_name ).handler .get_value (
314- result .outputs , trait_name )
317+ if result .outputs .trait (trait_name ).is_trait_type (OutputMultiPath ):
318+ old = result .outputs .trait (trait_name ).handler .get_value (
319+ result .outputs , trait_name )
315320 value = resolve_path_traits (result .outputs .trait (trait_name ), old ,
316321 results_file .parent )
317322 setattr (result .outputs , trait_name , value )
0 commit comments