Fix lint and tests (#1959)
* refactor(chat.py): rename flow_id variable to flow_id_str for better clarity refactor(chat.py): update flow_id usage to flow_id_str in build_vertex function for consistency refactor(chat.py): change flow_id to flow_id_str in build_vertex function for consistency refactor(chat.py): replace flow_id with flow_id_str in build_vertex function for consistency refactor(chat.py): update flow_id to flow_id_str in build_vertex_stream function for consistency refactor(chat.py): change flow_id to flow_id_str in build_vertex_stream function for consistency refactor(chat.py): replace flow_id with flow_id_str in build_vertex_stream function for consistency refactor(chat.py): update flow_id to flow_id_str in build_vertex_stream function for consistency refactor(endpoints.py): replace flow_id with flow_id_str in simplified_run_flow function for consistency refactor(endpoints.py): update flow_id to flow_id_str in simplified_run_flow function for consistency refactor(endpoints.py): change flow_id to flow_id_str in simplified_run_flow function for consistency refactor(endpoints.py): replace flow_id with flow_id_str in simplified_run_flow function for consistency refactor(endpoints.py): update flow_id to flow_id_str in simplified_run_flow function for consistency refactor(endpoints.py): change flow_id to flow_id_str in simplified_run_flow function for consistency refactor(endpoints.py): replace flow_id with flow_id_str in simplified_run_flow function for consistency refactor(endpoints.py): update flow_id to flow_id_str in simplified_run_flow function for consistency refactor(endpoints.py): change flow_id to flow_id_str in experimental_run_flow function for consistency refactor(endpoints.py): replace flow_id with flow_id_str in experimental_run_flow function for consistency refactor(endpoints.py): update flow_id to flow_id_str in experimental_run_flow function for consistency refactor(endpoints.py): change flow_id to flow_id_str in experimental_run_flow function for consistency refactor(endpoints.py): replace flow_id with flow_id_str in experimental_run_flow function for consistency refactor(endpoints.py): update flow_id to flow_id_str in experimental_run_flow function for consistency refactor(endpoints.py): change flow_id to flow_id_str in experimental_run_flow function for consistency refactor(endpoints.py): replace flow_id with flow_id_str in experimental_run_flow function for consistency refactor(endpoints.py): update flow_id fix(files.py): update variable names from flow_id to flow_id_str for consistency feat(files.py): use flow_id_str instead of flow_id for file operations to ensure correct folder paths feat(files.py): improve error handling and response messages in file operations feat(flows.py): optimize query for fetching example flows feat(folders.py): refactor create_folder function for better readability and maintainability feat(folders.py): update_folder function to handle excluded_flows and concat_folder_components feat(folders.py): improve error handling and response messages in folder operations feat(folders.py): optimize query for fetching folder in download_file function feat(schemas.py): update FlowListReadWithFolderName schema field names to name and description feat(OpenAIConversationalAgent.py): add support for using pydantic SecretStr for storing API key securely feat(ChatOpenAISpecs.py): add support for using pydantic SecretStr for storing API key securely refactor(RecordsOutput.py): change base class from TextComponent to CustomComponent refactor(base.py): remove unused import and log_transaction call refactor(model.py): change components and flows fields to have default_factory=list refactor(utils.py): update SQLModel import and use Field for components and flows fields refactor(service.py): change table_map declaration to use type hints for better readability * feat(tests): add import statement for Folder model in conftest.py to support new functionality refactor(tests): update query in conftest.py to use nested query for Folder name refactor(tests): update import statement for UUID in test_endpoints.py refactor(tests): update UUID usage in test_endpoints.py for consistency and clarity refactor(tests): update UUID usage in test_endpoints.py for consistency and clarity refactor(tests): update UUID usage in test_endpoints.py for consistency and clarity refactor(tests): update UUID usage in test_endpoints.py for consistency and clarity feat(tests): add import statement for Folder model in test_initial_setup.py to support new functionality refactor(tests): update query in test_initial_setup.py to use Folder model for better readability and maintainability * new lock
This commit is contained in:
parent
9141bbbb86
commit
c7f5e4f843
18 changed files with 498 additions and 482 deletions
|
|
@ -15,6 +15,7 @@ from langflow.initial_setup.setup import STARTER_FOLDER_NAME
|
|||
from langflow.services.auth.utils import get_password_hash
|
||||
from langflow.services.database.models.api_key.model import ApiKey
|
||||
from langflow.services.database.models.flow.model import Flow, FlowCreate
|
||||
from langflow.services.database.models.folder.model import Folder
|
||||
from langflow.services.database.models.user.model import User, UserCreate
|
||||
from langflow.services.database.utils import session_getter
|
||||
from langflow.services.deps import get_db_service
|
||||
|
|
@ -388,7 +389,9 @@ def get_starter_project(active_user):
|
|||
# once the client is created, we can get the starter project
|
||||
with session_getter(get_db_service()) as session:
|
||||
flow = session.exec(
|
||||
select(Flow).where(Flow.folder == STARTER_FOLDER_NAME).where(Flow.name == "Basic Prompting (Hello, World)")
|
||||
select(Flow)
|
||||
.where(Flow.folder.has(Folder.name == STARTER_FOLDER_NAME))
|
||||
.where(Flow.name == "Basic Prompting (Hello, World)")
|
||||
).first()
|
||||
if not flow:
|
||||
raise ValueError("No starter project found")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import time
|
||||
from uuid import uuid4
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
import pytest
|
||||
from fastapi import status
|
||||
|
|
@ -393,8 +393,9 @@ def test_various_prompts(client, prompt, expected_input_variables):
|
|||
|
||||
|
||||
def test_get_vertices_flow_not_found(client, logged_in_headers):
|
||||
response = client.post("/api/v1/build/nonexistent_id/vertices", headers=logged_in_headers)
|
||||
assert response.status_code == 500 # Or whatever status code you've set for invalid ID
|
||||
uuid = uuid4()
|
||||
response = client.post(f"/api/v1/build/{uuid}/vertices", headers=logged_in_headers)
|
||||
assert response.status_code == 500
|
||||
|
||||
|
||||
def test_get_vertices(client, added_flow_with_prompt_and_history, logged_in_headers):
|
||||
|
|
@ -414,7 +415,8 @@ def test_get_vertices(client, added_flow_with_prompt_and_history, logged_in_head
|
|||
|
||||
|
||||
def test_build_vertex_invalid_flow_id(client, logged_in_headers):
|
||||
response = client.post("/api/v1/build/nonexistent_id/vertices/vertex_id", headers=logged_in_headers)
|
||||
uuid = uuid4()
|
||||
response = client.post(f"/api/v1/build/{uuid}/vertices/vertex_id", headers=logged_in_headers)
|
||||
assert response.status_code == 500
|
||||
|
||||
|
||||
|
|
@ -652,7 +654,11 @@ def test_invalid_flow_id(client, created_api_key):
|
|||
headers = {"x-api-key": created_api_key.api_key}
|
||||
flow_id = "invalid-flow-id"
|
||||
response = client.post(f"/api/v1/run/{flow_id}", headers=headers)
|
||||
assert response.status_code == status.HTTP_404_NOT_FOUND
|
||||
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, response.text
|
||||
headers = {"x-api-key": created_api_key.api_key}
|
||||
flow_id = UUID(int=0)
|
||||
response = client.post(f"/api/v1/run/{flow_id}", headers=headers)
|
||||
assert response.status_code == status.HTTP_404_NOT_FOUND, response.text
|
||||
# Check if the error detail is as expected
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from sqlmodel import select
|
||||
|
||||
from langflow.initial_setup.setup import (
|
||||
STARTER_FOLDER_NAME,
|
||||
create_or_update_starter_projects,
|
||||
get_project_data,
|
||||
load_starter_projects,
|
||||
)
|
||||
from langflow.services.database.models.flow.model import Flow
|
||||
from langflow.services.database.models.folder.model import Folder
|
||||
from langflow.services.deps import session_scope
|
||||
from sqlalchemy import func
|
||||
from sqlmodel import select
|
||||
|
||||
|
||||
def test_load_starter_projects():
|
||||
|
|
@ -50,7 +50,8 @@ def test_create_or_update_starter_projects(client):
|
|||
num_projects = len(load_starter_projects())
|
||||
|
||||
# Get the number of projects in the database
|
||||
num_db_projects = session.exec(select(func.count(Flow.id)).where(Flow.folder == STARTER_FOLDER_NAME)).one()
|
||||
folder = session.exec(select(Folder).where(Folder.name == STARTER_FOLDER_NAME)).first()
|
||||
num_db_projects = len(folder.flows)
|
||||
|
||||
# Check that the number of projects in the database is the same as the number of projects returned by load_starter_projects
|
||||
assert num_db_projects == num_projects
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue