Rename stop_vertex to component

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-02-22 18:28:27 -03:00
commit 58769f587f
2 changed files with 7 additions and 7 deletions

View file

@ -85,7 +85,7 @@ async def try_running_celery_task(vertex, user_id):
@router.get("/build/{flow_id}/vertices", response_model=VerticesOrderResponse) @router.get("/build/{flow_id}/vertices", response_model=VerticesOrderResponse)
async def get_vertices( async def get_vertices(
flow_id: str, flow_id: str,
stop_vertex_id: Optional[str] = None, stop_component_id: Optional[str] = None,
chat_service: "ChatService" = Depends(get_chat_service), chat_service: "ChatService" = Depends(get_chat_service),
session=Depends(get_session), session=Depends(get_session),
): ):
@ -96,9 +96,9 @@ async def get_vertices(
if cache := chat_service.get_cache(flow_id): if cache := chat_service.get_cache(flow_id):
graph: Graph = cache.get("result") graph: Graph = cache.get("result")
graph = build_and_cache_graph(flow_id, session, chat_service, graph) graph = build_and_cache_graph(flow_id, session, chat_service, graph)
if stop_vertex_id: if stop_component_id:
try: try:
vertices = graph.sort_vertices(stop_vertex_id) vertices = graph.sort_vertices(stop_component_id)
except Exception as exc: except Exception as exc:
logger.error(exc) logger.error(exc)
vertices = graph.sort_vertices() vertices = graph.sort_vertices()

View file

@ -520,11 +520,11 @@ class Graph:
return vertices_layers return vertices_layers
def sort_vertices(self, stop_vertex_id: Optional[str] = None) -> List[List[str]]: def sort_vertices(self, stop_component_id: Optional[str] = None) -> List[List[str]]:
"""Sorts the vertices in the graph.""" """Sorts the vertices in the graph."""
if stop_vertex_id: if stop_component_id:
self.stop_vertex = stop_vertex_id self.stop_vertex = stop_component_id
vertices = self.sort_up_to_vertex(stop_vertex_id) vertices = self.sort_up_to_vertex(stop_component_id)
else: else:
vertices = self.vertices vertices = self.vertices
vertices_layers = self.layered_topological_sort(vertices) vertices_layers = self.layered_topological_sort(vertices)