Skip to content

Commit f3a34a7

Browse files
committed
fix internal functions
1 parent da9a348 commit f3a34a7

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

python_workflow_definition/src/python_workflow_definition/cwl/__main__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55

66

77
def 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):
2623
if __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

python_workflow_definition/src/python_workflow_definition/cwl/export.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,12 @@ def _write_function_cwl(workflow):
108108
"outputs": {},
109109
}
110110
file_name = function_nodes_dict[i].split(".")[-1] + "_" + str(i) + ".cwl"
111-
template["inputs"]["workflowfile"]["default"]["location"] = (
112-
function_nodes_dict[i].split(".")[0] + ".py"
113-
)
111+
if function_nodes_dict[i].split(".")[0] != "python_workflow_defintion":
112+
template["inputs"]["workflowfile"]["default"]["location"] = (
113+
function_nodes_dict[i].split(".")[0] + ".py"
114+
)
115+
else:
116+
del template["inputs"]["workflowfile"]
114117
template["inputs"].update(
115118
_get_function_template(function_name=function_nodes_dict[i])
116119
)

0 commit comments

Comments
 (0)