* feat(utils.py): add escape_json_dump function to escape JSON strings for Edge dictionaries * refactor(Output): streamline add_types method to prevent duplicate entries in types list for improved type management * feat(data.py): add classmethod decorator to validate_data for enhanced validation logic when checking data types * feat(setup.py): implement retry logic for loading starter projects to enhance robustness against JSON decode errors * fix(input_mixin.py): improve model_config formatting and update field_type alias for clarity and consistency in field definitions * feat(types.py): refactor vertex constructors to use NodeData and add input/output methods for better component interaction * feat(schema.py): add NodeData and Position TypedDicts for improved type safety and structure in vertex data handling * feat(base.py): update Vertex to use NodeData type and add to_data method for better data management and access * refactor(schema.py): update TargetHandle and SourceHandle models to include model_config attribute * Add TypedDict classes for graph schema serialization in `schema.py` * Refactor `Edge` class to improve handle validation and data handling - Consolidated imports and removed redundant `BaseModel` definitions for `SourceHandle` and `TargetHandle`. - Added `valid_handles`, `target_param`, and `_target_handle` attributes to `Edge` class. - Enhanced handle validation logic to distinguish between dictionary and string types. - Introduced `to_data` method to return edge data. - Updated attribute names to follow consistent naming conventions (`base_classes`, `input_types`, `field_name`). * Refactor `Edge` class to improve handle validation and data handling * Refactor: Standardize attribute naming and add `to_data` method in Edge class - Renamed attributes to use snake_case consistently (`baseClasses` to `base_classes`, `inputTypes` to `input_types`, `fieldName` to `field_name`). - Added `to_data` method to return `_data` attribute. - Updated validation methods to use new attribute names. * Refactor: Update Edge class to consistently use snake_case for attributes and improve validation logic for handles * Refactor: Change node argument type in add_node and _create_vertex methods to NodeData for better type safety and clarity * Refactor: Implement JSON serialization for graph data with `dumps` and `dump` methods, enhancing data export capabilities * Refactor: Add pytest fixtures for ingestion and RAG graphs, enhance test structure for better clarity and organization * Refactor: Add pytest fixtures for memory_chatbot_graph tests and improve test structure * Refactor: Remove unused methods in ComponentVertex class to streamline code and improve readability * Refactor: Remove unnecessary line in ComponentVertex class to enhance code clarity and maintainability * Refactor: Update import path for DefaultPromptField to improve code organization and maintainability in api_utils.py * Refactor: Update import path for DefaultPromptField to enhance code organization and maintainability in prompt.py * fix: Remove fixture in test_memory_chatbot.py that blocked db setup * Refactor: Add durations path for unit tests to improve test reporting * Refactor: Add splitting algorithm option for unit tests * Add async option to Makefile for unit tests and update GitHub Actions workflow - Introduced `async` variable in Makefile to conditionally run unit tests with or without parallel execution. - Updated `unit_tests` target in Makefile to handle `async` flag. - Modified GitHub Actions workflow to set `async=false` for unit tests.
94 lines
3.1 KiB
YAML
94 lines
3.1 KiB
YAML
name: Python tests
|
|
|
|
on:
|
|
workflow_call:
|
|
workflow_dispatch:
|
|
inputs:
|
|
branch:
|
|
description: "(Optional) Branch to checkout"
|
|
required: false
|
|
type: string
|
|
env:
|
|
POETRY_VERSION: "1.8.2"
|
|
NODE_VERSION: "21"
|
|
|
|
jobs:
|
|
build:
|
|
name: Unit Tests - Python ${{ matrix.python-version }} - Group ${{ matrix.group }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version:
|
|
- "3.12"
|
|
- "3.11"
|
|
- "3.10"
|
|
splitCount: [5]
|
|
group: [1, 2, 3, 4, 5]
|
|
env:
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.branch || github.ref }}
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
id: setup-node
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
|
|
uses: "./.github/actions/poetry_caching"
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
poetry-version: ${{ env.POETRY_VERSION }}
|
|
cache-key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
|
|
- name: Install Python dependencies
|
|
run: |
|
|
poetry env use ${{ matrix.python-version }}
|
|
poetry install
|
|
- name: Run unit tests
|
|
uses: nick-fields/retry@v3
|
|
with:
|
|
timeout_minutes: 12
|
|
max_attempts: 2
|
|
command: make unit_tests async=false args="--splits ${{ matrix.splitCount }} --group ${{ matrix.group }}"
|
|
|
|
test-cli:
|
|
name: Test CLI - Python ${{ matrix.python-version }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version:
|
|
- "3.12"
|
|
- "3.11"
|
|
- "3.10"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
|
|
uses: "./.github/actions/poetry_caching"
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
poetry-version: ${{ env.POETRY_VERSION }}
|
|
cache-key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
|
|
- name: Build wheel
|
|
run: |
|
|
poetry env use ${{ matrix.python-version }}
|
|
make build main=true
|
|
- name: Install wheel
|
|
run: |
|
|
python -m pip install dist/*.whl
|
|
- name: Test CLI
|
|
run: |
|
|
python -m langflow run --host 127.0.0.1 --port 7860 --backend-only &
|
|
SERVER_PID=$!
|
|
# Wait for the server to start
|
|
timeout 120 bash -c 'until curl -f http://127.0.0.1:7860/api/v1/auto_login; do sleep 5; done' || (echo "Server did not start in time" && kill $SERVER_PID && exit 1)
|
|
# Terminate the server
|
|
kill $SERVER_PID || (echo "Failed to terminate the server" && exit 1)
|
|
sleep 10 # give the server some time to terminate
|
|
# Check if the server is still running
|
|
if kill -0 $SERVER_PID 2>/dev/null; then
|
|
echo "Failed to terminate the server"
|
|
exit 1
|
|
else
|
|
echo "Server terminated successfully"
|
|
fi
|