darabos commited on
Commit
6568046
·
1 Parent(s): b662a59

Start updating "Create graph" box. It can take multiple inputs now.

Browse files
lynxkite-graph-analytics/src/lynxkite_graph_analytics/core.py CHANGED
@@ -137,8 +137,15 @@ def nx_node_attribute_func(name):
137
 
138
  def disambiguate_edges(ws: workspace.Workspace):
139
  """If an input plug is connected to multiple edges, keep only the last edge."""
 
 
140
  seen = set()
141
  for edge in reversed(ws.edges):
 
 
 
 
 
142
  if (edge.target, edge.targetHandle) in seen:
143
  i = ws.edges.index(edge)
144
  del ws.edges[i]
@@ -174,6 +181,7 @@ def _execute_node(node, ws, catalog, outputs):
174
  node.publish_error("Operation not found in catalog")
175
  return
176
  node.publish_started()
 
177
  input_map = {
178
  edge.targetHandle: outputs[edge.source]
179
  for edge in ws.edges
 
137
 
138
  def disambiguate_edges(ws: workspace.Workspace):
139
  """If an input plug is connected to multiple edges, keep only the last edge."""
140
+ catalog = ops.CATALOGS[ws.env]
141
+ nodes = {node.id: node for node in ws.nodes}
142
  seen = set()
143
  for edge in reversed(ws.edges):
144
+ dst_node = nodes[edge.target]
145
+ op = catalog.get(dst_node.data.title)
146
+ if op.inputs[edge.targetHandle].type == list[Bundle]:
147
+ # Takes multiple bundles as an input. No need to disambiguate.
148
+ continue
149
  if (edge.target, edge.targetHandle) in seen:
150
  i = ws.edges.index(edge)
151
  del ws.edges[i]
 
181
  node.publish_error("Operation not found in catalog")
182
  return
183
  node.publish_started()
184
+ # TODO: Handle multi-inputs.
185
  input_map = {
186
  edge.targetHandle: outputs[edge.source]
187
  for edge in ws.edges
lynxkite-graph-analytics/src/lynxkite_graph_analytics/lynxkite_ops.py CHANGED
@@ -320,7 +320,7 @@ def view_tables(bundle: core.Bundle, *, limit: int = 100):
320
  view="graph_creation_view",
321
  outputs=["output"],
322
  )
323
- def create_graph(bundle: core.Bundle, *, relations: str = None) -> core.Bundle:
324
  """Replace relations of the given bundle
325
 
326
  relations is a stringified JSON, instead of a dict, because complex Yjs types (arrays, maps)
 
320
  view="graph_creation_view",
321
  outputs=["output"],
322
  )
323
+ def create_graph(bundle: list[core.Bundle], *, relations: str = None) -> core.Bundle:
324
  """Replace relations of the given bundle
325
 
326
  relations is a stringified JSON, instead of a dict, because complex Yjs types (arrays, maps)