Update package versions, workflows, LLMChain and Graph sorting (#1674)
* Update package versions in pyproject.toml and poetry.lock files * Update poetry caching action and workflows * Update poetry caching action and workflows * Refactor LLMChainComponent build method in LLMChain.py * Update poetry install command in Makefile * Refactor Makefile to remove redundant install_backend targets * Fix codespell issues in project * Update package versions and dependencies * Fix import order in chat_io.spec.ts, headerComponent/index.tsx, and chatMessage/index.tsx * Update ruff command in Makefile and fix poetry cache reuse in Dockerfile * Refactor ServiceManager class in manager.py to handle default service factories * Fix typo in DOWNLOAD_WEBHOOK_URL variable assignment * Refactor cache_service tests in test_cache_manager.py * Add pytest-profiling * Update Makefile to run unit tests with parallel execution * Refactor ServiceManager class in manager.py to handle default service factories * Refactor node_name condition in Graph class to use "Listen" instead of "GetNotified" * Refactor file paths in tests/conftest.py for better readability and maintainability * Sort vertices in each layer by dependency in Graph class * Refactor variable declaration in SessionService class to use type hinting * Refactor make tests command in python_test.yml workflow * Refactor file paths in tests/conftest.py for better readability and maintainability * Refactor imports in tests/conftest.py to include sqlmodel.Session and related dependencies * Refactor file paths in tests/conftest.py to include available files in error message * Refactor file paths in tests/conftest.py to include available files in error message * Refactor file paths in tests/conftest.py to fix typo in BasicChatwithPromptAndHistory.json
This commit is contained in:
parent
836ac08d80
commit
e582535bb0
23 changed files with 396 additions and 286 deletions
|
|
@ -10,6 +10,7 @@ import orjson
|
|||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from httpx import AsyncClient
|
||||
from sqlmodel import Session, SQLModel, create_engine, select
|
||||
from langflow.graph.graph.base import Graph
|
||||
from langflow.initial_setup.setup import STARTER_FOLDER_NAME
|
||||
from langflow.services.auth.utils import get_password_hash
|
||||
|
|
@ -27,25 +28,39 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
def pytest_configure():
|
||||
pytest.BASIC_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "basic_example.json"
|
||||
pytest.COMPLEX_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "complex_example.json"
|
||||
pytest.COMPLEX_DEPS_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "complex_deps_example.json"
|
||||
pytest.OPENAPI_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "Openapi.json"
|
||||
pytest.GROUPED_CHAT_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "grouped_chat.json"
|
||||
pytest.ONE_GROUPED_CHAT_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "one_group_chat.json"
|
||||
pytest.VECTOR_STORE_GROUPED_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "vector_store_grouped.json"
|
||||
data_path = Path(__file__).parent.absolute() / "data"
|
||||
|
||||
pytest.BASIC_CHAT_WITH_PROMPT_AND_HISTORY = (
|
||||
Path(__file__).parent.absolute() / "data" / "BasicChatWithPromptAndHistory.json"
|
||||
)
|
||||
pytest.CHAT_INPUT = Path(__file__).parent.absolute() / "data" / "ChatInputTest.json"
|
||||
pytest.TWO_OUTPUTS = Path(__file__).parent.absolute() / "data" / "TwoOutputsTest.json"
|
||||
pytest.VECTOR_STORE_PATH = Path(__file__).parent.absolute() / "data" / "Vector_store.json"
|
||||
pytest.BASIC_EXAMPLE_PATH = data_path / "basic_example.json"
|
||||
pytest.COMPLEX_EXAMPLE_PATH = data_path / "complex_example.json"
|
||||
pytest.OPENAPI_EXAMPLE_PATH = data_path / "Openapi.json"
|
||||
pytest.GROUPED_CHAT_EXAMPLE_PATH = data_path / "grouped_chat.json"
|
||||
pytest.ONE_GROUPED_CHAT_EXAMPLE_PATH = data_path / "one_group_chat.json"
|
||||
pytest.VECTOR_STORE_GROUPED_EXAMPLE_PATH = data_path / "vector_store_grouped.json"
|
||||
|
||||
pytest.BASIC_CHAT_WITH_PROMPT_AND_HISTORY = data_path / "BasicChatwithPromptandHistory.json"
|
||||
pytest.CHAT_INPUT = data_path / "ChatInputTest.json"
|
||||
pytest.TWO_OUTPUTS = data_path / "TwoOutputsTest.json"
|
||||
pytest.VECTOR_STORE_PATH = data_path / "Vector_store.json"
|
||||
pytest.CODE_WITH_SYNTAX_ERROR = """
|
||||
def get_text():
|
||||
retun "Hello World"
|
||||
"""
|
||||
|
||||
# validate that all the paths are correct and the files exist
|
||||
for path in [
|
||||
pytest.BASIC_EXAMPLE_PATH,
|
||||
pytest.COMPLEX_EXAMPLE_PATH,
|
||||
pytest.OPENAPI_EXAMPLE_PATH,
|
||||
pytest.GROUPED_CHAT_EXAMPLE_PATH,
|
||||
pytest.ONE_GROUPED_CHAT_EXAMPLE_PATH,
|
||||
pytest.VECTOR_STORE_GROUPED_EXAMPLE_PATH,
|
||||
pytest.BASIC_CHAT_WITH_PROMPT_AND_HISTORY,
|
||||
pytest.CHAT_INPUT,
|
||||
pytest.TWO_OUTPUTS,
|
||||
pytest.VECTOR_STORE_PATH,
|
||||
]:
|
||||
assert path.exists(), f"File {path} does not exist. Available files: {list(data_path.iterdir())}"
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def check_openai_api_key_in_environment_variables():
|
||||
|
|
@ -192,16 +207,6 @@ def json_vector_store():
|
|||
return f.read()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def complex_graph_with_groups():
|
||||
with open(pytest.COMPLEX_DEPS_EXAMPLE_PATH, "r") as f:
|
||||
flow_graph = json.load(f)
|
||||
data_graph = flow_graph["data"]
|
||||
nodes = data_graph["nodes"]
|
||||
edges = data_graph["edges"]
|
||||
return Graph(nodes, edges)
|
||||
|
||||
|
||||
@pytest.fixture(name="client", autouse=True)
|
||||
def client_fixture(session: Session, monkeypatch, request):
|
||||
# Set the database url to a test database
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue