Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change ValueError into Warning to allow disconnected flows to run and other small fixes #3249

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/backend/base/langflow/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ async def event_generator(queue: asyncio.Queue, client_consumed_queue: asyncio.Q
try:
await asyncio.gather(*tasks)
except asyncio.CancelledError:
background_tasks.add_task(graph.end_all_traces)
for task in tasks:
task.cancel()
return
Expand Down
3 changes: 2 additions & 1 deletion src/backend/base/langflow/graph/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from functools import partial
from itertools import chain
from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional, Tuple, Type, Union
import warnings

import nest_asyncio
from loguru import logger
Expand Down Expand Up @@ -1425,7 +1426,7 @@ def _build_edges(self) -> List[ContractEdge]:
new_edge = self.build_edge(edge)
edges.add(new_edge)
if self.vertices and not edges:
raise ValueError("Graph has vertices but no edges")
warnings.warn("Graph has vertices but no edges")
return list(edges)

def build_edge(self, edge: EdgeData) -> ContractEdge:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/tests/unit/graph/graph/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def test_graph():
graph = Graph()
graph.add_component("chat_input", chat_input)
graph.add_component("chat_output", chat_output)
with pytest.raises(ValueError, match="Graph has vertices but no edges"):
with pytest.warns(UserWarning, match="Graph has vertices but no edges"):
graph.prepare()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test_vector_store_rag_dump_components_and_edges(ingestion_graph, rag_graph):
assert (source, target) in expected_rag_edges, f"Edge {source} -> {target} not found"


def test_vector_store_rag_add(ingestion_graph, rag_graph):
def test_vector_store_rag_add(ingestion_graph: Graph, rag_graph: Graph):
ingestion_graph_copy = copy.deepcopy(ingestion_graph)
rag_graph_copy = copy.deepcopy(rag_graph)
ingestion_graph_copy += rag_graph_copy
Expand Down
4 changes: 2 additions & 2 deletions src/backend/tests/unit/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test_create_flows(client: TestClient, session: Session, json_flow: str, logg
# Check response data
response_data = response.json()
assert len(response_data) == 2
assert response_data[0]["name"] == "Flow 1"
assert "Flow 1" in response_data[0]["name"]
assert response_data[0]["description"] == "description"
assert response_data[0]["data"] == data
assert response_data[1]["name"] == "Flow 2"
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_upload_file(client: TestClient, session: Session, json_flow: str, logge
# Check response data
response_data = response.json()
assert len(response_data) == 2
assert response_data[0]["name"] == "Flow 1"
assert "Flow 1" in response_data[0]["name"]
assert response_data[0]["description"] == "description"
assert response_data[0]["data"] == data
assert response_data[1]["name"] == "Flow 2"
Expand Down
Loading