Fix duplicated first layer results
This commit is contained in:
parent
2b17919883
commit
eca66c518d
1 changed files with 10 additions and 4 deletions
|
|
@ -65,19 +65,25 @@ async def get_vertices(
|
||||||
graph = await build_and_cache_graph(flow_id, session, chat_service, graph)
|
graph = await build_and_cache_graph(flow_id, session, chat_service, graph)
|
||||||
if stop_component_id or start_component_id:
|
if stop_component_id or start_component_id:
|
||||||
try:
|
try:
|
||||||
vertices = graph.sort_vertices(stop_component_id, start_component_id)
|
first_layer = graph.sort_vertices(stop_component_id, start_component_id)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(exc)
|
logger.error(exc)
|
||||||
vertices = graph.sort_vertices()
|
first_layer = graph.sort_vertices()
|
||||||
else:
|
else:
|
||||||
vertices = graph.sort_vertices()
|
first_layer = graph.sort_vertices()
|
||||||
|
# When we send vertices to the frontend
|
||||||
|
# we need to remove them from the predecessors
|
||||||
|
# so they are not considered for building again
|
||||||
|
# which duplicates the results
|
||||||
|
for vertex_id in first_layer:
|
||||||
|
graph.remove_from_predecessors(vertex_id)
|
||||||
|
|
||||||
# Now vertices is a list of lists
|
# Now vertices is a list of lists
|
||||||
# We need to get the id of each vertex
|
# We need to get the id of each vertex
|
||||||
# and return the same structure but only with the ids
|
# and return the same structure but only with the ids
|
||||||
run_id = uuid.uuid4()
|
run_id = uuid.uuid4()
|
||||||
graph.set_run_id(run_id)
|
graph.set_run_id(run_id)
|
||||||
return VerticesOrderResponse(ids=vertices, run_id=run_id)
|
return VerticesOrderResponse(ids=first_layer, run_id=run_id)
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(f"Error checking build status: {exc}")
|
logger.error(f"Error checking build status: {exc}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue