diff --git a/README.md b/README.md index 291287a..29f3ccf 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ python test_persistence.py ### 3. API 使用 ```python -from workflow_service.comfy.comfy_server import server_manager +from app.comfy.comfy_server import server_manager # 注册服务器 await server_manager.register_server( diff --git a/workflow_service/comfy/comfy_queue.py b/app/comfy/comfy_queue.py similarity index 93% rename from workflow_service/comfy/comfy_queue.py rename to app/comfy/comfy_queue.py index 099be22..b6df6fa 100644 --- a/workflow_service/comfy/comfy_queue.py +++ b/app/comfy/comfy_queue.py @@ -4,10 +4,10 @@ from typing import Any, Optional import aiohttp -from workflow_service.comfy.comfy_workflow import ComfyWorkflow -from workflow_service.comfy.comfy_run import ComfyRun -from workflow_service.config import Settings -from workflow_service.comfy.comfy_server import server_manager, ComfyUIServerInfo +from app.comfy.comfy_workflow import ComfyWorkflow +from app.comfy.comfy_run import ComfyRun +from app.config import Settings +from app.comfy.comfy_server import server_manager, ComfyUIServerInfo settings = Settings() @@ -125,11 +125,10 @@ class WorkflowQueueManager: # 格式化状态信息,提高可读性 status_info = ( - f"⏰ 定时检测触发 [{timestamp}]\n" - f" 📋 待处理任务: {pending_count} 个\n" - f" 🚀 运行中任务: {running_count} 个\n" - f" ⏱️ 监控间隔: {self._monitor_interval} 秒\n" - f" 🕐 {time_since_last_processing}" + f"⏰ 定时检测触发 [{timestamp}]\t" + f"待处理/运行中: {pending_count}/{running_count}\t" + f"监控间隔: {self._monitor_interval} 秒\t" + f"🕐 {time_since_last_processing}" ) logger.info(status_info) diff --git a/workflow_service/comfy/comfy_run.py b/app/comfy/comfy_run.py similarity index 98% rename from workflow_service/comfy/comfy_run.py rename to app/comfy/comfy_run.py index 8d28002..2bb96bf 100644 --- a/workflow_service/comfy/comfy_run.py +++ b/app/comfy/comfy_run.py @@ -8,9 +8,9 @@ import aiohttp import websockets from aiohttp import ClientTimeout -from workflow_service.comfy.comfy_workflow import ComfyWorkflow, API_OUTPUT_PREFIX -from workflow_service.comfy.comfy_server import ComfyUIServerInfo, server_manager -from workflow_service.database.api import ( +from app.comfy.comfy_workflow import ComfyWorkflow, API_OUTPUT_PREFIX +from app.comfy.comfy_server import ComfyUIServerInfo, server_manager +from app.database.api import ( create_workflow_run, create_workflow_run_nodes, get_workflow_run, diff --git a/workflow_service/comfy/comfy_server.py b/app/comfy/comfy_server.py similarity index 99% rename from workflow_service/comfy/comfy_server.py rename to app/comfy/comfy_server.py index 82ff26d..e144c21 100644 --- a/workflow_service/comfy/comfy_server.py +++ b/app/comfy/comfy_server.py @@ -13,8 +13,8 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy import select, update, delete from sqlalchemy.orm import selectinload -from workflow_service.database.connection import AsyncSessionLocal -from workflow_service.database.models import ComfyUIServer as ComfyUIServerModel +from app.database.connection import AsyncSessionLocal +from app.database.models import ComfyUIServer as ComfyUIServerModel logger = logging.getLogger(__name__) diff --git a/workflow_service/comfy/comfy_workflow.py b/app/comfy/comfy_workflow.py similarity index 99% rename from workflow_service/comfy/comfy_workflow.py rename to app/comfy/comfy_workflow.py index 6175ba7..211e54f 100644 --- a/workflow_service/comfy/comfy_workflow.py +++ b/app/comfy/comfy_workflow.py @@ -3,7 +3,7 @@ from typing import Any, Dict, List, Optional, Union import aiohttp from pydantic import BaseModel -from workflow_service.comfy.comfy_server import ComfyUIServerInfo +from app.comfy.comfy_server import ComfyUIServerInfo logging.basicConfig(level=logging.INFO) diff --git a/workflow_service/config.py b/app/config.py similarity index 100% rename from workflow_service/config.py rename to app/config.py diff --git a/workflow_service/database/__init__.py b/app/database/__init__.py similarity index 100% rename from workflow_service/database/__init__.py rename to app/database/__init__.py diff --git a/workflow_service/database/api.py b/app/database/api.py similarity index 100% rename from workflow_service/database/api.py rename to app/database/api.py diff --git a/workflow_service/database/connection.py b/app/database/connection.py similarity index 96% rename from workflow_service/database/connection.py rename to app/database/connection.py index d7b0e26..440dfc7 100644 --- a/workflow_service/database/connection.py +++ b/app/database/connection.py @@ -7,7 +7,7 @@ from sqlalchemy import create_engine from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker from sqlalchemy.orm import sessionmaker -from workflow_service.config import Settings +from app.config import Settings # 数据库配置 DATABASE_FILE = Settings().DB_FILE diff --git a/workflow_service/database/models.py b/app/database/models.py similarity index 100% rename from workflow_service/database/models.py rename to app/database/models.py diff --git a/workflow_service/main.py b/app/main.py similarity index 87% rename from workflow_service/main.py rename to app/main.py index b033705..31179ad 100644 --- a/workflow_service/main.py +++ b/app/main.py @@ -7,11 +7,11 @@ from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.staticfiles import StaticFiles -from workflow_service.comfy.comfy_server import server_manager -from workflow_service.database.api import init_db -from workflow_service.config import Settings -from workflow_service.routes import service, workflow, run, runx, comfy_server -from workflow_service.comfy.comfy_queue import queue_manager +from app.comfy.comfy_server import server_manager +from app.database.api import init_db +from app.config import Settings +from app.routes import service, workflow, run, runx, comfy_server +from app.comfy.comfy_queue import queue_manager settings = Settings() diff --git a/workflow_service/routes/__init__.py b/app/routes/__init__.py similarity index 100% rename from workflow_service/routes/__init__.py rename to app/routes/__init__.py diff --git a/workflow_service/routes/comfy_server.py b/app/routes/comfy_server.py similarity index 98% rename from workflow_service/routes/comfy_server.py rename to app/routes/comfy_server.py index b9c3ff0..1a2cbaa 100644 --- a/workflow_service/routes/comfy_server.py +++ b/app/routes/comfy_server.py @@ -5,7 +5,7 @@ import logging import aiohttp import asyncio -from workflow_service.comfy.comfy_server import server_manager +from app.comfy.comfy_server import server_manager logger = logging.getLogger(__name__) diff --git a/workflow_service/routes/run.py b/app/routes/run.py similarity index 97% rename from workflow_service/routes/run.py rename to app/routes/run.py index f96df76..7cce50e 100644 --- a/workflow_service/routes/run.py +++ b/app/routes/run.py @@ -5,9 +5,9 @@ from datetime import datetime, timedelta from fastapi import APIRouter, Body, HTTPException from fastapi.responses import JSONResponse -from workflow_service.comfy.comfy_queue import queue_manager -from workflow_service.comfy.comfy_workflow import ComfyWorkflow -from workflow_service.database.api import ( +from app.comfy.comfy_queue import queue_manager +from app.comfy.comfy_workflow import ComfyWorkflow +from app.database.api import ( get_workflow, get_workflow_run, get_workflow_run_nodes, diff --git a/workflow_service/routes/runx/__init__.py b/app/routes/runx/__init__.py similarity index 100% rename from workflow_service/routes/runx/__init__.py rename to app/routes/runx/__init__.py diff --git a/workflow_service/routes/runx/_base.py b/app/routes/runx/_base.py similarity index 100% rename from workflow_service/routes/runx/_base.py rename to app/routes/runx/_base.py diff --git a/workflow_service/routes/runx/model_with_multi_dress.py b/app/routes/runx/model_with_multi_dress.py similarity index 94% rename from workflow_service/routes/runx/model_with_multi_dress.py rename to app/routes/runx/model_with_multi_dress.py index 3f9b47f..ce0c567 100644 --- a/workflow_service/routes/runx/model_with_multi_dress.py +++ b/app/routes/runx/model_with_multi_dress.py @@ -3,9 +3,9 @@ from typing import Optional from fastapi import Body, HTTPException from fastapi.responses import JSONResponse -from workflow_service.comfy.comfy_queue import queue_manager -from workflow_service.comfy.comfy_workflow import ComfyWorkflow -from workflow_service.database.api import get_workflow +from app.comfy.comfy_queue import queue_manager +from app.comfy.comfy_workflow import ComfyWorkflow +from app.database.api import get_workflow from ._base import runx_router RUNX_NAME = "model_with_multi_dress" diff --git a/workflow_service/routes/service.py b/app/routes/service.py similarity index 93% rename from workflow_service/routes/service.py rename to app/routes/service.py index cf1b9e6..3fbc7e5 100644 --- a/workflow_service/routes/service.py +++ b/app/routes/service.py @@ -6,9 +6,9 @@ import aiohttp from fastapi import APIRouter, HTTPException, Path from pydantic import BaseModel -from workflow_service.comfy.comfy_queue import queue_manager -from workflow_service.comfy.comfy_server import server_manager -from workflow_service.config import Settings +from app.comfy.comfy_queue import queue_manager +from app.comfy.comfy_server import server_manager +from app.config import Settings settings = Settings() diff --git a/workflow_service/routes/workflow.py b/app/routes/workflow.py similarity index 96% rename from workflow_service/routes/workflow.py rename to app/routes/workflow.py index f4ad2f5..6ef1acd 100644 --- a/workflow_service/routes/workflow.py +++ b/app/routes/workflow.py @@ -4,8 +4,8 @@ from typing import Optional, List from fastapi import APIRouter, Body, HTTPException, Path from fastapi.responses import JSONResponse -from workflow_service.comfy.comfy_workflow import ComfyWorkflow -from workflow_service.database.api import ( +from app.comfy.comfy_workflow import ComfyWorkflow +from app.database.api import ( save_workflow, get_all_workflows, delete_workflow, diff --git a/workflow_service/static/css/monitor.css b/app/static/css/monitor.css similarity index 100% rename from workflow_service/static/css/monitor.css rename to app/static/css/monitor.css diff --git a/workflow_service/static/index.html b/app/static/index.html similarity index 100% rename from workflow_service/static/index.html rename to app/static/index.html diff --git a/workflow_service/static/js/monitor.js b/app/static/js/monitor.js similarity index 100% rename from workflow_service/static/js/monitor.js rename to app/static/js/monitor.js diff --git a/workflow_service/utils/s3_client.py b/app/utils/s3_client.py similarity index 95% rename from workflow_service/utils/s3_client.py rename to app/utils/s3_client.py index bdeebc0..594137a 100644 --- a/workflow_service/utils/s3_client.py +++ b/app/utils/s3_client.py @@ -1,5 +1,5 @@ import boto3 -from workflow_service.config import Settings +from app.config import Settings import asyncio settings = Settings() diff --git a/modal_deploy.py b/modal_deploy.py index f7b780a..d51e535 100644 --- a/modal_deploy.py +++ b/modal_deploy.py @@ -1,6 +1,6 @@ import modal from dotenv import dotenv_values -from workflow_service.main import web_app +from app.main import web_app fastapi_image = ( modal.Image.debian_slim(python_version="3.11") diff --git a/run_service.py b/run_service.py index c92682d..64b176a 100644 --- a/run_service.py +++ b/run_service.py @@ -23,7 +23,7 @@ project_root = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, project_root) # 现在可以正常导入 -from workflow_service.main import web_app +from app.main import web_app import uvicorn print("🚀 启动 ComfyUI 工作流服务监控...")