feat: VRSub 单体应用(WOV 单机版)初始提交
为视频生成 VR 双眼字幕的单体实现:FastAPI 后端、调度器与全部节点 (提音/转写/翻译/ASS/抽帧/OCR/LLM 过滤)在单进程内运行。 - 节点协议(wov_sdk 数据模型)与分布式版保持一致,预留回退桥梁 - 工作流即数据:DAG 存于 workflows/*.json,模型/链路改动只改数据 - 调度器:拓扑顺序执行、断点续跑(产物重建)、任务暂停/继续 - 抽帧按帧间隔(select 按帧号精确取帧),VLM OCR 与 LLM 过滤使用 自适应线程池弹性并发,并打印数据处理速度进度日志 - 100% 行覆盖率(pytest --cov-fail-under=100)
This commit is contained in:
Executable
+50
@@ -0,0 +1,50 @@
|
||||
"""Echo 节点。
|
||||
|
||||
单体版中作为进程内节点模块存在,由调度器直接调用 invoke 处理器,不再启动
|
||||
独立 HTTP 服务。保留该节点用于验证节点协议与注册表链路。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from wov_sdk.models import InvokeRequest, InvokeResponse
|
||||
|
||||
def _resolve_input_text(request: InvokeRequest, node_root: Path) -> str:
|
||||
"""按优先级解析输入文本:直接文本 > 文件 URI > 默认字符串。"""
|
||||
# 优先使用请求中直接携带的 text 字段。
|
||||
text = request.inputs.get("text")
|
||||
if text is not None:
|
||||
return str(text)
|
||||
|
||||
# 其次读取 file_uri 指向的文件;相对路径以单体根目录为基准。
|
||||
file_uri = request.inputs.get("file_uri")
|
||||
if file_uri:
|
||||
path = Path(file_uri)
|
||||
if not path.is_absolute():
|
||||
path = node_root / path
|
||||
return path.read_text(encoding="utf-8")
|
||||
|
||||
# 都没有时返回固定文本,保证节点总有可演示的输出。
|
||||
return "echo"
|
||||
|
||||
|
||||
def invoke(request: InvokeRequest) -> InvokeResponse:
|
||||
"""处理节点调用:把解析出的文本写入产物并返回 URI。"""
|
||||
# 单体根目录用于解析相对文件路径(nodes/ 的上一级)。
|
||||
node_root = Path(__file__).resolve().parent.parent
|
||||
output_dir = Path(request.output_dir)
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
text = _resolve_input_text(request, node_root)
|
||||
# 产物必须落在请求给定的 output_dir,调度器按 run 与节点组织目录。
|
||||
output_path = output_dir / "echo.txt"
|
||||
output_path.write_text(text, encoding="utf-8")
|
||||
|
||||
return InvokeResponse(
|
||||
status="completed",
|
||||
outputs={
|
||||
"text": text,
|
||||
"file_uri": str(output_path),
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user