44import importlib .util
55
66
7- def load_function (funct ):
8- p , m = funct .rsplit ("." , 1 )
9- spec = importlib .util .spec_from_file_location (p , p + ".py" )
7+ def load_function (file_name , funct ):
8+ spec = importlib .util .spec_from_file_location ("workflow" , file_name )
109 module = importlib .util .module_from_spec (spec )
11- sys .modules [p ] = module
10+ sys .modules ["workflow" ] = module
1211 spec .loader .exec_module (module )
13- return getattr (module , m )
12+ return getattr (module , funct )
1413
1514
1615def convert_argument (arg ):
@@ -24,19 +23,17 @@ def convert_argument(arg):
2423if __name__ == "__main__" :
2524 # load input
2625 argument_lst = sys .argv [1 :]
27- funct = [
28- load_function (funct = arg .split ("=" )[- 1 ])
29- for arg in argument_lst
30- if "--function=" in arg
31- ][0 ]
26+ funct = [arg .split ("=" )[- 1 ] for arg in argument_lst if "--function=" in arg ][0 ]
27+ file = [arg .split ("=" )[- 1 ] for arg in argument_lst if "--workflowfile=" in arg ][0 ]
28+ workflow_function = load_function (file_name = file , funct = funct )
3229 kwargs = {
3330 arg .split ("=" )[0 ][6 :]: convert_argument (arg = arg .split ("=" )[- 1 ])
3431 for arg in argument_lst
3532 if "--arg_" in arg
3633 }
3734
3835 # evaluate function
39- result = funct (** kwargs )
36+ result = workflow_function (** kwargs )
4037
4138 # store output
4239 if isinstance (result , dict ):
0 commit comments