@@ -289,12 +289,25 @@ def nipype_module(self):
289
289
290
290
@property
291
291
def all_import_translations (self ) -> ty .List [ty .Tuple [str , str ]]:
292
- return self .import_translations + [
292
+ all_translations = self .import_translations + [
293
293
(r"nipype\.interfaces\.mrtrix3.\w+\b" , r"pydra.tasks.mrtrix3.v3_0" ),
294
294
(r"nipype\.interfaces\.(?!base)(\w+)\b" , r"pydra.tasks.\1.auto" ),
295
- (r"nipype\.(.*)" , self .name + r".nipype_ports.\1" ),
296
- (self .nipype_name , self .name ),
297
295
]
296
+ if self .interface_only :
297
+ all_translations .extend (
298
+ [
299
+ (r"nipype\.(.*)" , self .name + r".auto.nipype_ports.\1" ),
300
+ (self .nipype_name , self .name + ".auto" ),
301
+ ]
302
+ )
303
+ else :
304
+ all_translations .extend (
305
+ [
306
+ (r"nipype\.(.*)" , self .name + r".nipype_ports.\1" ),
307
+ (self .nipype_name , self .name ),
308
+ ]
309
+ )
310
+ return all_translations
298
311
299
312
@property
300
313
def all_omit_modules (self ) -> ty .List [str ]:
@@ -450,7 +463,7 @@ def collect_intra_pkg_objects(used: UsedSymbols, port_nipype: bool = True):
450
463
"." .join (cp_pkg .split ("." )[1 :]),
451
464
)
452
465
output_pkg_fspath = self .to_fspath (
453
- package_root , self .to_output_module_path (cp_pkg )
466
+ package_root , self .nipype2pydra_module_name (cp_pkg )
454
467
)
455
468
output_pkg_fspath .parent .mkdir (parents = True , exist_ok = True )
456
469
shutil .copytree (
@@ -508,7 +521,7 @@ def write_intra_pkg_modules(
508
521
if not objs :
509
522
continue
510
523
511
- out_mod_name = self .to_output_module_path (mod_name )
524
+ out_mod_name = self .nipype2pydra_module_name (mod_name )
512
525
513
526
if mod_name == self .name :
514
527
raise NotImplementedError (
@@ -568,7 +581,7 @@ def write_intra_pkg_modules(
568
581
import_find_replace = self .import_find_replace ,
569
582
)
570
583
571
- def to_output_module_path (self , nipype_module_path : str ) -> str :
584
+ def nipype2pydra_module_name (self , nipype_name : str ) -> str :
572
585
"""Converts an original Nipype module path to a Pydra module path
573
586
574
587
Parameters
@@ -581,17 +594,20 @@ def to_output_module_path(self, nipype_module_path: str) -> str:
581
594
str
582
595
the Pydra module path
583
596
"""
584
- base_pkg = self .name + ".__init__"
585
- relative_to = self .nipype_name
586
- if re .match (self .nipype_module .__name__ + r"\b" , nipype_module_path ):
587
- if self .interface_only :
588
- base_pkg = self .name + ".auto.__init__"
589
- elif re .match (r"^nipype\b" , nipype_module_path ):
590
- base_pkg = self .name + ".nipype_ports.__init__"
597
+ if self .interface_only :
598
+ base_pkg = self .name + ".auto"
599
+ else :
600
+ base_pkg = self .name
601
+ if re .match (self .nipype_module .__name__ + r"\b" , nipype_name ):
602
+ relative_to = self .nipype_name
603
+ elif re .match (r"^nipype\b" , nipype_name ):
604
+ base_pkg += ".nipype_ports"
591
605
relative_to = "nipype"
606
+ else :
607
+ return nipype_name
592
608
return ImportStatement .join_relative_package (
593
- base_pkg ,
594
- ImportStatement .get_relative_package (nipype_module_path , relative_to ),
609
+ base_pkg + ".__init__" ,
610
+ ImportStatement .get_relative_package (nipype_name , relative_to ),
595
611
)
596
612
597
613
@classmethod
@@ -684,9 +700,11 @@ def nipype_port_converters(self) -> ty.Dict[str, interface.BaseInterfaceConverte
684
700
with open (spec_file , "r" ) as f :
685
701
spec = yaml .safe_load (f )
686
702
callables_file = spec_file .parent / (spec_file .stem + "_callables.py" )
687
- module_name = "." .join (
688
- [self .name , "nipype_ports" ] + spec ["nipype_module" ].split ("." )[1 :]
689
- )
703
+ if self .interface_only :
704
+ mod_base = [self .name , "auto" , "nipype_ports" ]
705
+ else :
706
+ mod_base = [self .name , "nipype_ports" ]
707
+ module_name = "." .join (mod_base + spec ["nipype_module" ].split ("." )[1 :])
690
708
task_name = spec ["task_name" ]
691
709
output_module = (
692
710
self .translate_submodule (
0 commit comments