refactor: 移除旧的comfyui_client模块,重构API路由以使用新的comfy_workflow和queue_manager,提升代码结构和可维护性

This commit is contained in:
iHeyTang
2025-08-14 14:29:17 +08:00
parent f6f07a094f
commit 6240b98c5b
8 changed files with 889 additions and 873 deletions

View File

@@ -4,7 +4,8 @@ from typing import Dict, Optional
from fastapi import APIRouter, Body, HTTPException
from fastapi.responses import JSONResponse
from workflow_service import comfyui_client
from workflow_service.comfy import comfy_workflow
from workflow_service.comfy.comfy_queue import queue_manager
from workflow_service.database.api import get_workflow
run_router = APIRouter(
@@ -38,10 +39,10 @@ async def run_workflow(
raise HTTPException(status_code=404, detail=detail)
workflow = json.loads(workflow_data["workflow_json"])
api_spec = comfyui_client.parse_api_spec(workflow)
api_spec = comfy_workflow.parse_api_spec(workflow)
# 提交到队列
workflow_run_id = await comfyui_client.submit_workflow_to_queue(
workflow_run_id = await queue_manager.add_task(
workflow_name=workflow_name,
workflow_data=workflow,
api_spec=api_spec,
@@ -67,7 +68,7 @@ async def get_run_status(workflow_run_id: str):
获取工作流执行状态。
"""
try:
status = await comfyui_client.queue_manager.get_task_status(workflow_run_id)
status = await queue_manager.get_task_status(workflow_run_id)
return status
except Exception as e:
raise HTTPException(status_code=500, detail=f"获取状态失败: {str(e)}")