Skip to content

Commit

Permalink
fix(runnable_vertices_manager.py): add recursive function to find pre…
Browse files Browse the repository at this point in the history
…decessors (langflow-ai#2593)

fix(runnable_vertices_manager.py): add recursive function to find runnable predecessors
  • Loading branch information
ogabrielluiz authored Jul 8, 2024
1 parent 311b663 commit 4c43b4c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/backend/base/langflow/graph/graph/runnable_vertices_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@ def find_runnable_predecessors_for_successors(self, vertex_id: str, inactivated_
runnable_vertices = []
visited = set()

def find_runnable_predecessors(predecessor_id: str):
if predecessor_id in visited:
return
visited.add(predecessor_id)
if self.is_vertex_runnable(predecessor_id, inactivated_vertices):
runnable_vertices.append(predecessor_id)
else:
for pred_pred_id in self.run_predecessors.get(predecessor_id, []):
find_runnable_predecessors(pred_pred_id)

for successor_id in self.run_map.get(vertex_id, []):
for predecessor_id in self.run_predecessors.get(successor_id, []):
if predecessor_id not in visited and self.is_vertex_runnable(predecessor_id, inactivated_vertices):
runnable_vertices.append(predecessor_id)
visited.add(predecessor_id)
find_runnable_predecessors(predecessor_id)

return runnable_vertices

def remove_from_predecessors(self, vertex_id: str):
Expand Down

0 comments on commit 4c43b4c

Please sign in to comment.