diff --git a/src/backend/base/langflow/__main__.py b/src/backend/base/langflow/__main__.py index 343188336..4234e892c 100644 --- a/src/backend/base/langflow/__main__.py +++ b/src/backend/base/langflow/__main__.py @@ -167,7 +167,7 @@ def run( else: # Run using gunicorn on Linux process = run_on_mac_or_linux(host, port, log_level, options, app) - if open_browser: + if open_browser and not backend_only: click.launch(f"http://{host}:{port}") if process: process.join() diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index b06cfc0a6..a6c1e830a 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -897,7 +897,7 @@ class Graph: next_runnable_vertices = await self._execute_tasks(tasks, lock=lock) except Exception as e: logger.error(f"Error executing tasks in layer {layer_index}: {e}") - break + raise e if not next_runnable_vertices: break to_process.extend(next_runnable_vertices) diff --git a/src/backend/base/langflow/initial_setup/setup.py b/src/backend/base/langflow/initial_setup/setup.py index 6d1572da6..075768db4 100644 --- a/src/backend/base/langflow/initial_setup/setup.py +++ b/src/backend/base/langflow/initial_setup/setup.py @@ -510,9 +510,9 @@ def load_flows_from_directory(): if existing: logger.info(f"Updating existing flow: {flow_id} with endpoint name {flow_endpoint_name}") for key, value in flow.items(): - if key == "last_tested_version": - continue - setattr(existing, key, value) + if hasattr(existing, key): + # flow dict from json and db representation are not 100% the same + setattr(existing, key, value) existing.updated_at = datetime.utcnow() existing.user_id = user_id session.add(existing) diff --git a/tests/conftest.py b/tests/conftest.py index efff896a7..7fb932ed8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,7 +35,9 @@ load_dotenv() def pytest_configure(config): config.addinivalue_line("markers", "noclient: don't create a client for this test") - data_path = Path(__file__).parent.absolute() / "data" + config.addinivalue_line("markers", "load_flows: load the flows for this test") + config.addinivalue_line("markers", "api_key_required: run only if the api key is set in the environment variables") + data_path = Path(__file__).parent.parent.absolute() / "data" pytest.BASIC_EXAMPLE_PATH = data_path / "basic_example.json" pytest.COMPLEX_EXAMPLE_PATH = data_path / "complex_example.json" diff --git a/tests/data/basic_example.json b/tests/data/basic_example.json index 35f515bc4..e3a5141a6 100644 --- a/tests/data/basic_example.json +++ b/tests/data/basic_example.json @@ -505,5 +505,6 @@ "y": 0, "zoom": 0.5 } - } -} \ No newline at end of file + }, + "last_tested_version": "0.6.2" +} diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py index e689f558d..e09f9f62e 100644 --- a/tests/unit/test_database.py +++ b/tests/unit/test_database.py @@ -6,7 +6,7 @@ from fastapi.testclient import TestClient from sqlmodel import Session from langflow.api.v1.schemas import FlowListCreate -from langflow.initial_setup.setup import load_starter_projects +from langflow.initial_setup.setup import load_starter_projects, load_flows_from_directory from langflow.services.database.models.base import orjson_dumps from langflow.services.database.models.flow import Flow, FlowCreate, FlowUpdate from langflow.services.database.utils import session_getter @@ -271,7 +271,11 @@ def test_read_only_starter_projects(client: TestClient, active_user, logged_in_h @pytest.mark.load_flows def test_load_flows(client: TestClient, load_flows_dir): - client.get("/api/v1/auto_login") + response = client.get("api/v1/flows/c54f9130-f2fa-4a3e-b22a-3856d946351b") + assert response.status_code == 200 + assert response.json()["name"] == "BasicExample" + # re-run to ensure updates work well + load_flows_from_directory() response = client.get("api/v1/flows/c54f9130-f2fa-4a3e-b22a-3856d946351b") assert response.status_code == 200 assert response.json()["name"] == "BasicExample" diff --git a/tests/unit/test_loading.py b/tests/unit/test_loading.py index 5872d060f..a3138f22c 100644 --- a/tests/unit/test_loading.py +++ b/tests/unit/test_loading.py @@ -33,6 +33,7 @@ def test_load_flow_from_json_object(): @pytest.mark.noclient +@pytest.mark.api_key_required def test_run_flow_from_json_object(): """Test loading a flow from a json file and applying tweaks""" _, projects = zip(*load_starter_projects())