Skip to content

Commit

Permalink
Rename Vertex._data to Vertex.full_data
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet committed Oct 22, 2024
1 parent 505dc63 commit 45377b5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/backend/base/langflow/graph/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ def update_vertex_from_another(self, vertex: Vertex, other_vertex: Vertex) -> No
vertex (Vertex): The vertex to be updated.
other_vertex (Vertex): The vertex to update from.
"""
vertex.data = other_vertex.data
vertex.full_data = other_vertex.full_data
vertex.parse_data()
# Now we update the edges of the vertex
self.update_edges_from_vertex(other_vertex)
Expand Down Expand Up @@ -1367,7 +1367,7 @@ async def build_vertex(
vertex.artifacts = cached_vertex_dict["artifacts"]
vertex.built_object = cached_vertex_dict["built_object"]
vertex.built_result = cached_vertex_dict["built_result"]
vertex.data = cached_vertex_dict["data"]
vertex.full_data = cached_vertex_dict["full_data"]
vertex.results = cached_vertex_dict["results"]
try:
vertex.finalize_build()
Expand All @@ -1394,7 +1394,7 @@ async def build_vertex(
"artifacts": vertex.artifacts,
"built_object": vertex.built_object,
"built_result": vertex.built_result,
"data": vertex.data,
"full_data": vertex.full_data,
}

await set_cache(key=vertex.id, data=vertex_dict)
Expand Down
12 changes: 4 additions & 8 deletions src/backend/base/langflow/graph/vertex/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
self.has_external_input = False
self.has_external_output = False
self.graph = graph
self.data = data.copy()
self.full_data = data.copy()
self.base_type: str | None = base_type
self.outputs: list[dict] = []
self.parse_data()
Expand All @@ -87,7 +87,7 @@ def __init__(
self.task_id: str | None = None
self.is_task = is_task
self.params = params or {}
self.parent_node_id: str | None = self.data.get("parent_node_id")
self.parent_node_id: str | None = self.full_data.get("parent_node_id")
self.load_from_db_fields: list[str] = []
self.parent_is_top_level = False
self.layer = None
Expand All @@ -113,7 +113,7 @@ def set_input_value(self, name: str, value: Any) -> None:
self.custom_component._set_input_value(name, value)

def to_data(self):
return self.data
return self.full_data

def add_component_instance(self, component_instance: Component) -> None:
component_instance.set_vertex(self)
Expand Down Expand Up @@ -216,7 +216,7 @@ def set_top_level(self, top_level_vertices: list[str]) -> None:
self.parent_is_top_level = self.parent_node_id in top_level_vertices

def parse_data(self) -> None:
self.data = self.data["data"]
self.data = self.full_data["data"]
if self.data["node"]["template"]["_type"] == "Component":
if "outputs" not in self.data["node"]:
msg = f"Outputs not found for {self.display_name}"
Expand Down Expand Up @@ -462,10 +462,6 @@ def update_raw_params(self, new_params: Mapping[str, str | list[str]], *, overwr
self.params = self.raw_params.copy()
self.updated_raw_params = True

def has_cycle_edges(self):
"""Checks if the vertex has any cycle edges."""
return self.has_cycle_edges

async def instantiate_component(self, user_id=None) -> None:
if not self.custom_component:
self.custom_component, _ = await initialize.loading.instantiate_class(
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/graph/vertex/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ async def _run(self, *args, **kwargs) -> None: # noqa: ARG002
self.built_object = Data(text=message, data=self.artifacts)
else:
self.built_object = message
self._built_result = self._built_object
self.built_result = self.built_object

async def stream(self):
iterator = self.params.get(INPUT_FIELD_NAME, None)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/tests/integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ def _add_component(clazz: type, inputs: dict | None = None) -> str:
_, _ = await run_graph_internal(
graph, flow_id, session_id=session_id, inputs=graph_run_inputs, outputs=[component_id]
)
return graph.get_vertex(component_id)._built_object
return graph.get_vertex(component_id).built_object
4 changes: 2 additions & 2 deletions src/backend/tests/unit/graph/graph/test_cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ def test_that_outputs_cache_is_set_to_false_in_cycle():

graph = Graph(chat_input, chat_output)
cycle_vertices = find_cycle_vertices(graph._get_edges_as_list_of_tuples())
cycle_outputs_lists = [graph.vertex_map[vertex_id]._custom_component.outputs for vertex_id in cycle_vertices]
cycle_outputs_lists = [graph.vertex_map[vertex_id].custom_component.outputs for vertex_id in cycle_vertices]
cycle_outputs = [output for outputs in cycle_outputs_lists for output in outputs]
for output in cycle_outputs:
assert output.cache is False

non_cycle_outputs_lists = [
vertex._custom_component.outputs for vertex in graph.vertices if vertex.id not in cycle_vertices
vertex.custom_component.outputs for vertex in graph.vertices if vertex.id not in cycle_vertices
]
non_cycle_outputs = [output for outputs in non_cycle_outputs_lists for output in outputs]
for output in non_cycle_outputs:
Expand Down

0 comments on commit 45377b5

Please sign in to comment.