darabos commited on
Commit
a3258ff
·
1 Parent(s): 848f538

Ignore invalid edges.

Browse files
lynxkite-app/src/lynxkite_app/crdt.py CHANGED
@@ -273,6 +273,7 @@ async def execute(name: str, ws_crdt: pycrdt.Map, ws_pyd: workspace.Workspace, d
273
  nc["data"]["status"] = "planned"
274
  # Nodes get a reference to their CRDT maps, so they can update them as the results come in.
275
  np._crdt = nc
 
276
  await workspace.execute(ws_pyd)
277
  workspace.save(ws_pyd, path)
278
  print(f"Finished running {name} in {ws_pyd.env}.")
 
273
  nc["data"]["status"] = "planned"
274
  # Nodes get a reference to their CRDT maps, so they can update them as the results come in.
275
  np._crdt = nc
276
+ ws_pyd = ws_pyd.normalize()
277
  await workspace.execute(ws_pyd)
278
  workspace.save(ws_pyd, path)
279
  print(f"Finished running {name} in {ws_pyd.env}.")
lynxkite-core/src/lynxkite/core/workspace.py CHANGED
@@ -97,6 +97,25 @@ class Workspace(BaseConfig):
97
  edges: list[WorkspaceEdge] = dataclasses.field(default_factory=list)
98
  _crdt: pycrdt.Map
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  async def execute(ws: Workspace):
102
  if ws.env in ops.EXECUTORS:
 
97
  edges: list[WorkspaceEdge] = dataclasses.field(default_factory=list)
98
  _crdt: pycrdt.Map
99
 
100
+ def normalize(self):
101
+ if self.env not in ops.CATALOGS:
102
+ return self
103
+ catalog = ops.CATALOGS[self.env]
104
+ _ops = {n.id: catalog[n.data.title] for n in self.nodes if n.data.title in catalog}
105
+ valid_targets = set(
106
+ (n.id, h) for n in self.nodes for h in _ops[n.id].inputs if n.id in _ops
107
+ )
108
+ valid_sources = set(
109
+ (n.id, h) for n in self.nodes for h in _ops[n.id].outputs if n.id in _ops
110
+ )
111
+ edges = [
112
+ edge
113
+ for edge in self.edges
114
+ if (edge.source, edge.sourceHandle) in valid_sources
115
+ and (edge.target, edge.targetHandle) in valid_targets
116
+ ]
117
+ return self.model_copy(update={"edges": edges})
118
+
119
 
120
  async def execute(ws: Workspace):
121
  if ws.env in ops.EXECUTORS: