@@ -13,10 +13,11 @@ def __init__(self, spec):
13
13
** self ._parse_workflow_args (self .spec ['args' ])
14
14
)
15
15
16
- def node_connections (self ):
16
+ def node_connections (self , workflow ):
17
17
connections = defaultdict (dict )
18
18
19
- for edge , props in self .wf ._graph .edges .items ():
19
+ # Get connections from workflow graph
20
+ for edge , props in workflow ._graph .edges .items ():
20
21
src_node = edge [0 ].name
21
22
dest_node = edge [1 ].name
22
23
for node_conn in props ['connect' ]:
@@ -29,11 +30,16 @@ def node_connections(self):
29
30
else :
30
31
src_field = src_field .split ('.' )[- 1 ]
31
32
connections [dest_node ][dest_field ] = f"{ src_node } .lzout.{ src_field } "
33
+
34
+ # Look for connections in nested workflows via recursion
35
+ for node in workflow .find_name_of_appropriate_method (): # TODO: find the method that iterates through the nodes of the workflow (but not nested nodes)
36
+ if isinstance (node , Workflow ): # TODO: find a way to check whether the node is a standard node or a nested workflow
37
+ connections .update (self .node_connections (node ))
32
38
return connections
33
39
34
40
def generate (self , format_with_black = False ):
35
41
36
- connections = self .node_connections ()
42
+ connections = self .node_connections (self . wf )
37
43
out_text = ""
38
44
for node_name in self .wf .list_node_names ():
39
45
node = self .wf .get_node (node_name )
@@ -51,15 +57,15 @@ def generate(self, format_with_black=False):
51
57
pass
52
58
if isinstance (val , str ) and '\n ' in val :
53
59
val = '"""' + val + '""""'
54
- node_args += f",\n { arg } ={ val } "
60
+ node_args += f",\n { arg } ={ val } "
55
61
56
62
for arg , val in connections [node .name ].items ():
57
- node_args += f",\n { arg } ={ val } "
63
+ node_args += f",\n { arg } =wf. { val } "
58
64
59
65
out_text += f"""
60
- wf.add({ task_type } (
61
- name="{ node .name } "{ node_args }
62
- )"""
66
+ wf.add({ task_type } (
67
+ name="{ node .name } "{ node_args }
68
+ )"""
63
69
64
70
if format_with_black :
65
71
out_text = black .format_file_contents (out_text , fast = False , mode = black .FileMode ())
0 commit comments