refactor: 修复sqlmodel的问题
* refactor: overhaul workflow and chat architecture - Separate Chat and Workflow API endpoints and database models - Use JSONB to store workflow execution context in Postgres - Convert workflow engine to use pydantic-ai execution graphs inside a Ray task - Update frontend React components to support standalone workflow creation - Remove obsolete and broken workflow runner tests Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com> * refactor: overhaul workflow and chat architecture - Separate Chat and Workflow API endpoints and database models - Use JSONB to store workflow execution context in Postgres - Convert workflow engine to use pydantic-ai execution graphs inside a Ray task - Update frontend React components to support standalone workflow creation - Remove obsolete and broken workflow runner tests Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com> * refactor: overhaul workflow and chat architecture - Separate Chat and Workflow API endpoints and database models - Use JSONB to store workflow execution context in Postgres - Convert workflow engine to use pydantic-ai execution graphs inside a Ray task - Update frontend React components to support standalone workflow creation - Move workflow_engine inside workflow package to keep core root clean - Remove obsolete and broken workflow runner tests Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com> * refactor: overhaul workflow and chat architecture - Separate Chat and Workflow API endpoints and database models - Use JSONB to store workflow execution context in Postgres - Convert workflow engine to use pydantic-ai execution graphs inside a Ray task - Update frontend React components to support standalone workflow creation - Move workflow_engine inside workflow package to keep core root clean - Replace sqlmodel with pure sqlalchemy mappings globally - Remove obsolete and broken workflow runner tests Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com> --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from sqlmodel import select
|
from sqlalchemy import select
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from kilostar.core.postgres_database.model.workflow import EventRecord
|
from kilostar.core.postgres_database.model.workflow import EventRecord
|
||||||
from sqlalchemy.ext.asyncio import async_sessionmaker, AsyncSession
|
from sqlalchemy.ext.asyncio import async_sessionmaker, AsyncSession
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from kilostar.core.postgres_database.model.individual import WorkerIndividual
|
from kilostar.core.postgres_database.model.individual import WorkerIndividual
|
||||||
from sqlmodel import select
|
from sqlalchemy import select
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from kilostar.core.postgres_database.database_exception import database_exception
|
from kilostar.core.postgres_database.database_exception import database_exception
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kilostar.core.postgres_database.model.provider import Provider
|
from kilostar.core.postgres_database.model.provider import Provider
|
||||||
from sqlmodel import select
|
from sqlalchemy import select
|
||||||
from kilostar.core.postgres_database.database_exception import database_exception
|
from kilostar.core.postgres_database.database_exception import database_exception
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from kilostar.core.postgres_database.model.system_node import SystemNodeConfig
|
from kilostar.core.postgres_database.model.system_node import SystemNodeConfig
|
||||||
from sqlmodel import select
|
from sqlalchemy import select
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from kilostar.core.postgres_database.database_exception import database_exception
|
from kilostar.core.postgres_database.database_exception import database_exception
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from kilostar.core.postgres_database.model.user import User
|
from kilostar.core.postgres_database.model.user import User
|
||||||
from sqlmodel import select
|
from sqlalchemy import select
|
||||||
from kilostar.utils.error import UserNotExistError, UserPasswordError
|
from kilostar.utils.error import UserNotExistError, UserPasswordError
|
||||||
from kilostar.core.postgres_database.database_exception import database_exception
|
from kilostar.core.postgres_database.database_exception import database_exception
|
||||||
from kilostar.core.postgres_database.model.user import UserAuthority
|
from kilostar.core.postgres_database.model.user import UserAuthority
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import asyncio
|
|||||||
import ray
|
import ray
|
||||||
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
|
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
from sqlmodel import SQLModel
|
from kilostar.core.postgres_database.model.base import BaseDataModel
|
||||||
|
|
||||||
from .module.individual import IndividualDatabase
|
from .module.individual import IndividualDatabase
|
||||||
from .module.event import EventDatabase
|
from .module.event import EventDatabase
|
||||||
@@ -64,7 +64,7 @@ class PostgresDatabase:
|
|||||||
Returns: (None): 经由当前业务模型加工处理后所输出的具体数据实例或领域模型对象。"""
|
Returns: (None): 经由当前业务模型加工处理后所输出的具体数据实例或领域模型对象。"""
|
||||||
try:
|
try:
|
||||||
async with self.async_engine.begin() as conn:
|
async with self.async_engine.begin() as conn:
|
||||||
await conn.run_sync(SQLModel.metadata.create_all)
|
await conn.run_sync(BaseDataModel.metadata.create_all)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Provide a warning if the database is not accessible, allowing
|
# Provide a warning if the database is not accessible, allowing
|
||||||
# the app to start up for development/UI tests without crashing immediately.
|
# the app to start up for development/UI tests without crashing immediately.
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
import pytest
|
|
||||||
from kilostar.core.workflow_running_engine.workflow import (
|
|
||||||
WorkStep,
|
|
||||||
kilostarWorkflow,
|
|
||||||
WorkflowStatus,
|
|
||||||
LogicGate,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_work_step():
|
|
||||||
ws = WorkStep(
|
|
||||||
step=1,
|
|
||||||
name="step1",
|
|
||||||
node="control_node",
|
|
||||||
action="coding",
|
|
||||||
desc="Write some code",
|
|
||||||
)
|
|
||||||
assert ws.step == 1
|
|
||||||
assert ws.name == "step1"
|
|
||||||
assert ws.node == "control_node"
|
|
||||||
assert ws.action == "coding"
|
|
||||||
assert ws.desc == "Write some code"
|
|
||||||
assert ws.status == "waiting"
|
|
||||||
|
|
||||||
|
|
||||||
def test_kilostar_workflow_validation_success():
|
|
||||||
ws1 = WorkStep(step=1, name="s1", node="control_node", action="a1", desc="d1")
|
|
||||||
ws2 = WorkStep(step=2, name="s2", node="regulatory_node", action="a2", desc="d2")
|
|
||||||
wf = kilostarWorkflow(
|
|
||||||
title="wf1",
|
|
||||||
work_link=[ws1, ws2],
|
|
||||||
trace_id="t",
|
|
||||||
event_info={"platform": "a", "user_name": "b"},
|
|
||||||
)
|
|
||||||
assert wf.title == "wf1"
|
|
||||||
|
|
||||||
|
|
||||||
def test_kilostar_workflow_validation_error_step_discontinuous():
|
|
||||||
ws1 = WorkStep(step=1, name="s1", node="control_node", action="a1", desc="d1")
|
|
||||||
ws2 = WorkStep(step=3, name="s3", node="regulatory_node", action="a2", desc="d2")
|
|
||||||
with pytest.raises(ValueError, match="工作链步数不连续"):
|
|
||||||
kilostarWorkflow(
|
|
||||||
title="wf1",
|
|
||||||
work_link=[ws1, ws2],
|
|
||||||
trace_id="t",
|
|
||||||
event_info={"platform": "a", "user_name": "b"},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_kilostar_workflow_validation_error_jump_out_of_bounds():
|
|
||||||
lg = LogicGate(if_fail="jump_to_step_3", if_pass="continue")
|
|
||||||
ws1 = WorkStep(
|
|
||||||
step=1, name="s1", node="control_node", action="a1", desc="d1", logic_gate=lg
|
|
||||||
)
|
|
||||||
ws2 = WorkStep(step=2, name="s2", node="regulatory_node", action="a2", desc="d2")
|
|
||||||
with pytest.raises(ValueError, match="跳转目标 Step 3 越界了"):
|
|
||||||
kilostarWorkflow(
|
|
||||||
title="wf1",
|
|
||||||
work_link=[ws1, ws2],
|
|
||||||
trace_id="t",
|
|
||||||
event_info={"platform": "a", "user_name": "b"},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_kilostar_workflow_validation_error_jump_format_error():
|
|
||||||
lg = LogicGate(if_fail="jump_to_step_invalid", if_pass="continue")
|
|
||||||
ws1 = WorkStep(
|
|
||||||
step=1, name="s1", node="control_node", action="a1", desc="d1", logic_gate=lg
|
|
||||||
)
|
|
||||||
with pytest.raises(ValueError, match="LogicGate 格式错误"):
|
|
||||||
kilostarWorkflow(
|
|
||||||
title="wf1",
|
|
||||||
work_link=[ws1],
|
|
||||||
trace_id="t",
|
|
||||||
event_info={"platform": "a", "user_name": "b"},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_workflow_status():
|
|
||||||
status = WorkflowStatus()
|
|
||||||
assert status.step == 1
|
|
||||||
assert status.status == "waiting_llm_working"
|
|
||||||
Reference in New Issue
Block a user