Merge remote-tracking branch 'origin/dev' into two_edges

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-06-20 13:41:00 -03:00
commit 47c0522c7b
7 changed files with 18 additions and 10 deletions

View file

@ -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()

View file

@ -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)

View file

@ -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)

View file

@ -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"

View file

@ -505,5 +505,6 @@
"y": 0,
"zoom": 0.5
}
}
}
},
"last_tested_version": "0.6.2"
}

View file

@ -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"

View file

@ -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())