2
2
from pathlib import Path
3
3
import typing as ty
4
4
import inspect
5
+ import sys
5
6
from importlib import import_module
6
7
from copy import copy
7
8
import black
@@ -57,7 +58,7 @@ class TaskConverter:
57
58
("\' MultiOutputFile\' " , "specs.MultiOutputFile" ),
58
59
]
59
60
60
- def __init__ (self , interface_spec , callables ):
61
+ def __init__ (self , interface_spec , callables_file ):
61
62
self .interface_spec = copy (interface_spec )
62
63
if self .interface_spec .get ("output_requirements" ) is None :
63
64
self .interface_spec ["output_requirements" ] = []
@@ -84,6 +85,10 @@ def __init__(self, interface_spec, callables):
84
85
self .cmd = nipype_interface ._cmd
85
86
self .nipype_input_spec = nipype_interface .input_spec ()
86
87
self .nipype_output_spec = nipype_interface .output_spec ()
88
+ sys .path .append (str (Path (callables_file ).resolve ().parent ))
89
+ self .callables_module = import_module (Path (callables_file ).stem )
90
+ sys .path .pop ()
91
+ # import callablescallables
87
92
88
93
def pydra_specs (self , write = False , dirname = None ):
89
94
"""creating pydra input/output spec from nipype specs
@@ -398,7 +403,7 @@ def function_callables(self):
398
403
fun_names = list (set (self .interface_spec ["output_callables" ].values ()))
399
404
fun_names .sort ()
400
405
for fun_nm in fun_names :
401
- fun = getattr (callables , fun_nm )
406
+ fun = getattr (self . callables_module , fun_nm )
402
407
fun_str += inspect .getsource (fun ) + "\n "
403
408
return fun_str
404
409
0 commit comments