HEL-892: expose source-reviewed workflow documentation in shared drawer
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""HEL-892 isolated browser host: production workflow router, no execution worker.
|
||||
|
||||
From repo root: .venv/bin/python e2e/workflow-document-server.py
|
||||
Run Vite on 5173 alongside it. No remote ComfyUI endpoint is configured.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
import uvicorn
|
||||
from calliope.comfyui.library import import_library
|
||||
from calliope.config import settings
|
||||
from calliope.db import get_db, migrate_db
|
||||
from calliope.routers import workflows
|
||||
from fastapi import FastAPI
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DATA = ROOT / '.local-evidence' / 'ui'
|
||||
settings.data_dir = DATA
|
||||
settings.db_name = 'library.db'
|
||||
settings.assets_dir = DATA / 'assets'
|
||||
settings.comfyui_endpoints = []
|
||||
settings.comfyui_base_url = 'http://127.0.0.1:1'
|
||||
app = FastAPI()
|
||||
app.include_router(workflows.router, prefix='/api/workflows')
|
||||
|
||||
|
||||
@app.get('/api/settings')
|
||||
def get_settings():
|
||||
return {'comfyui_endpoints': [], 'comfyui_active_id': None}
|
||||
|
||||
|
||||
def prepare():
|
||||
DATA.mkdir(parents=True, exist_ok=True)
|
||||
asyncio.run(migrate_db(settings.db_path))
|
||||
conn = get_db(settings.db_path)
|
||||
try:
|
||||
print(import_library(conn, ROOT / 'example_ComfyUI_workflows', source_commit='ui-browser'))
|
||||
for name, document in [
|
||||
('旧工作流回退(隔离测试夹具)', None),
|
||||
('空说明回退(隔离测试夹具)', '{}'),
|
||||
]:
|
||||
if conn.execute('SELECT id FROM workflows WHERE name=?', (name,)).fetchone():
|
||||
continue
|
||||
conn.execute(
|
||||
'INSERT INTO workflows(name,kind,workflow_json,input_schema,description,'
|
||||
'is_enabled,doc_json) VALUES (?,?,?,?,?,?,?)',
|
||||
(name, 'image', '{}', '[]', '隔离库旧条目回退测试;不代表真实工作流。', 0, document),
|
||||
)
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
prepare()
|
||||
uvicorn.run(app, host='127.0.0.1', port=8247)
|
||||
Reference in New Issue
Block a user