fix: Improve vertex filtering and update is_vertex_runnable logic (#2612)
* feat: improve is_vertex_runnable method in RunnableVerticesManager This commit improves the `is_vertex_runnable` method in the `RunnableVerticesManager` class. It adds an additional parameter `activated_vertices` to the method signature and updates the logic to check if a vertex is runnable based on the presence of activated vertices. This enhancement improves the accuracy of determining whether a vertex is runnable or not. * fix: add predecessors to vertices_to_run * style: fix lint issues * feat: optimize vertex filtering in useFlowStore This commit optimizes the vertex filtering logic in the `useFlowStore` function in `flowStore.ts`. It introduces a more efficient way to filter out vertices that are already being built, resulting in improved performance and accuracy. * refactor: add is_active method to Vertex class This commit adds the `is_active` method to the `Vertex` class in the `base.py` file. The `is_active` method checks if the state of the vertex is set to `ACTIVE` and returns a boolean value accordingly. This enhancement improves the readability and maintainability of the codebase. * refactor: improve is_vertex_runnable method in RunnableVerticesManager * refactor: improve find_runnable_predecessors_for_successors method in Graph class * refactor: move test_create_function
This commit is contained in:
parent
46966d164d
commit
d28fe8eedc
5 changed files with 51 additions and 36 deletions
|
|
@ -510,11 +510,23 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
const top_level_vertices = vertexBuildData.top_level_vertices.filter(
|
||||
(vertex) => !vertexBuildData.inactivated_vertices?.includes(vertex),
|
||||
);
|
||||
const nextVertices: VertexLayerElementType[] = zip(
|
||||
let nextVertices: VertexLayerElementType[] = zip(
|
||||
next_vertices_ids,
|
||||
top_level_vertices,
|
||||
).map(([id, reference]) => ({ id: id!, reference }));
|
||||
|
||||
// Now we filter nextVertices to remove any vertices that are in verticesLayers
|
||||
// because they are already being built
|
||||
// each layer is a list of vertexlayerelementtypes
|
||||
let lastLayer =
|
||||
get().verticesBuild!.verticesLayers[
|
||||
get().verticesBuild!.verticesLayers.length - 1
|
||||
];
|
||||
nextVertices = nextVertices.filter(
|
||||
(vertex) =>
|
||||
!lastLayer.some((layer) => layer.id === vertex.id) &&
|
||||
!lastLayer.some((layer) => layer.reference === vertex.reference),
|
||||
);
|
||||
const newLayers = [
|
||||
...get().verticesBuild!.verticesLayers,
|
||||
nextVertices,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue