From fdad49764a53d5f1e98416ebff1579678090178d Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Thu, 6 Feb 2025 16:08:41 -0300 Subject: [PATCH] Refactor: Simplify Vertex Queue Initialization by Removing is_input_vertex Dependency (#6155) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 📝 (vertex_types.py): improve default value assignment logic based on edge type for ComponentVertex class * [autofix.ci] apply automated fixes * 📝 (schema.py): remove TextInput from INPUT_COMPONENTS list as it is no longer used ♻️ (vertex_types.py): refactor default_value assignment logic for ComponentVertex class to improve readability and maintainability * ✨ (schema.py): introduce new TextInput component to the list of INPUT_COMPONENTS for the graph schema * 📝 (vertex_types.py): improve default value assignment logic based on edge type for ComponentVertex class * [autofix.ci] apply automated fixes * 🐛 (utils.py): fix layered topological sort to prevent TextInput from being incorrectly placed at the start * ♻️ (vertex_types.py): Remove unnecessary comment about getting default value based on edge type to improve code readability and maintainability. * 🐛 (vertex_types.py): simplify default value assignment logic for cycle edges --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida --- src/backend/base/langflow/graph/graph/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/graph/graph/utils.py b/src/backend/base/langflow/graph/graph/utils.py index 1be0cc7cb..c3c28151b 100644 --- a/src/backend/base/langflow/graph/graph/utils.py +++ b/src/backend/base/langflow/graph/graph/utils.py @@ -457,7 +457,7 @@ def layered_topological_sort( predecessor_map: dict[str, list[str]], start_id: str | None = None, cycle_vertices: set[str] | None = None, - is_input_vertex: Callable[[str], bool] | None = None, + is_input_vertex: Callable[[str], bool] | None = None, # noqa: ARG001 *, is_cyclic: bool = False, ) -> list[list[str]]: @@ -503,7 +503,9 @@ def layered_topological_sort( queue = deque( vertex_id for vertex_id in vertices_ids - if in_degree_map[vertex_id] == 0 or (is_input_vertex and is_input_vertex(vertex_id)) + if in_degree_map[vertex_id] == 0 + # We checked if it is input but that caused the TextInput to be at the start + # or (is_input_vertex and is_input_vertex(vertex_id)) ) layers: list[list[str]] = []