55
66
77def load_function (file_name , funct ):
8- if file_name .split ("/" )[- 1 ] != "python_workflow_definition.py" :
9- spec = importlib .util .spec_from_file_location ("workflow" , file_name )
10- module = importlib .util .module_from_spec (spec )
11- sys .modules ["workflow" ] = module
12- spec .loader .exec_module (module )
13- else :
14- module = importlib .import_module ("python_workflow_definition.shared" )
8+ spec = importlib .util .spec_from_file_location ("workflow" , file_name )
9+ module = importlib .util .module_from_spec (spec )
10+ sys .modules ["workflow" ] = module
11+ spec .loader .exec_module (module )
1512 return getattr (module , funct .split ("." )[- 1 ])
1613
1714
@@ -26,9 +23,13 @@ def convert_argument(arg):
2623if __name__ == "__main__" :
2724 # load input
2825 argument_lst = sys .argv [1 :]
29- funct = [arg .split ("=" )[- 1 ] for arg in argument_lst if "--function=" in arg ][0 ]
30- file = [arg .split ("=" )[- 1 ] for arg in argument_lst if "--workflowfile=" in arg ][0 ]
31- workflow_function = load_function (file_name = file , funct = funct )
26+ funct_lst = [arg .split ("=" )[- 1 ] for arg in argument_lst if "--function=" in arg ]
27+ file_lst = [arg .split ("=" )[- 1 ] for arg in argument_lst if "--workflowfile=" in arg ]
28+ if len (file_lst ) > 0 :
29+ workflow_function = load_function (file_name = file_lst [0 ], funct = funct_lst [0 ])
30+ else :
31+ m , p = funct_lst [0 ].rsplit ("." , 1 )
32+ workflow_function = importlib .import_module (m )
3233 kwargs = {
3334 arg .split ("=" )[0 ][6 :]: convert_argument (arg = arg .split ("=" )[- 1 ])
3435 for arg in argument_lst
0 commit comments