feat: 预览渲染进度实时上报(0%→10%→30%→40%→80%→85%→95%→100%)
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m5s
CI/CD Pipeline / Validate - Code Quality (push) Failing after 5m14s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 52s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 44s
CI/CD Pipeline / Unit Tests (push) Successful in 8m52s
CI/CD Pipeline / Integration Tests (push) Successful in 1m25s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 3m18s
CI/CD Pipeline / Build Staging API Image (push) Successful in 12m19s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m32s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 5m24s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m37s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 7m19s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 7m27s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 47s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 48s
AI Code Review / AI Code Review (pull_request) Successful in 54s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 56s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m26s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m41s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 24s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 26s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m31s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m3s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m4s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m35s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m25s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 7m4s
CI/CD Pipeline / CI Gate (pull_request) Failing after 6s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1075h14m26s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1075h14m26s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1075h14m27s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1075h14m27s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 1075h21m32s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 1075h21m32s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1075h14m27s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1075h22m16s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1075h22m16s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1075h22m20s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1075h22m20s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1075h22m20s
CI/CD Pipeline / Canary Release to Production (push) Failing after 1078h23m7s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1078h34m57s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1078h34m59s
CI/CD Pipeline / Deploy Production (push) Failing after 1078h34m57s
CI/CD Pipeline / Build Production API Image (push) Failing after 1078h34m59s
CI/CD Pipeline / CI Gate (push) Failing after 1078h34m58s
CI/CD Pipeline / PR Build Web Image (push) Failing after 1078h43m52s
CI/CD Pipeline / PR Build API Image (push) Failing after 1078h43m52s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1078h43m54s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 1075h47m41s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 1075h54m45s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1075h55m31s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1075h55m33s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1079h8m13s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 1079h17m7s
CI/CD Pipeline / Frontend Lint (push) Failing after 1079h17m8s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m5s
CI/CD Pipeline / Validate - Code Quality (push) Failing after 5m14s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 52s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 44s
CI/CD Pipeline / Unit Tests (push) Successful in 8m52s
CI/CD Pipeline / Integration Tests (push) Successful in 1m25s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 3m18s
CI/CD Pipeline / Build Staging API Image (push) Successful in 12m19s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m32s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 5m24s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m37s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 7m19s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 7m27s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 47s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 48s
AI Code Review / AI Code Review (pull_request) Successful in 54s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 56s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m26s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m41s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 24s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 26s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m31s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m3s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m4s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m35s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m25s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 7m4s
CI/CD Pipeline / CI Gate (pull_request) Failing after 6s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1075h14m26s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1075h14m26s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1075h14m27s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1075h14m27s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 1075h21m32s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 1075h21m32s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1075h14m27s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1075h22m16s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1075h22m16s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1075h22m20s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1075h22m20s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1075h22m20s
CI/CD Pipeline / Canary Release to Production (push) Failing after 1078h23m7s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1078h34m57s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1078h34m59s
CI/CD Pipeline / Deploy Production (push) Failing after 1078h34m57s
CI/CD Pipeline / Build Production API Image (push) Failing after 1078h34m59s
CI/CD Pipeline / CI Gate (push) Failing after 1078h34m58s
CI/CD Pipeline / PR Build Web Image (push) Failing after 1078h43m52s
CI/CD Pipeline / PR Build API Image (push) Failing after 1078h43m52s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1078h43m54s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 1075h47m41s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 1075h54m45s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1075h55m31s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1075h55m33s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1079h8m13s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 1079h17m7s
CI/CD Pipeline / Frontend Lint (push) Failing after 1079h17m8s
新增 _update_task_progress 辅助函数,在渲染流程6个关键节点更新进度: - 10%: 任务启动 - 30%: 素材下载完成 - 40%: 开始渲染 - 80%: 渲染完成 - 85%: 开始上传OSS - 95%: 上传完成 修复前端预览生成进度始终显示0%的问题。
This commit is contained in:
@@ -95,6 +95,42 @@ def _update_task_status(task_id: str, status_action: str, **kwargs) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def _update_task_progress(task_id: str, progress: float, stage: str = "") -> bool:
|
||||
"""更新 GenerationTask 进度(独立 session,异常不向外抛出)。
|
||||
|
||||
Args:
|
||||
task_id: 任务 ID
|
||||
progress: 进度值(0-100)
|
||||
stage: 阶段描述(仅用于日志)
|
||||
|
||||
Returns:
|
||||
True 表示更新成功
|
||||
"""
|
||||
try:
|
||||
from packages.adapters.sqlalchemy_impl.models import GenerationTaskModel
|
||||
|
||||
session = SessionLocal()
|
||||
try:
|
||||
model = session.query(GenerationTaskModel).filter(
|
||||
GenerationTaskModel.id == task_id
|
||||
).first()
|
||||
if model:
|
||||
model.progress = progress
|
||||
session.commit()
|
||||
if stage:
|
||||
logger.info(
|
||||
"GenerationTask 进度更新: task_id=%s progress=%.0f%% stage=%s",
|
||||
task_id, progress, stage,
|
||||
)
|
||||
return True
|
||||
return False
|
||||
finally:
|
||||
session.close()
|
||||
except Exception as e:
|
||||
logger.error("更新任务进度异常: task_id=%s progress=%s error=%s", task_id, progress, e)
|
||||
return False
|
||||
|
||||
# ── 日志持久化辅助 ────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -1283,6 +1319,7 @@ def generate_video(self, task_id: str) -> dict:
|
||||
|
||||
# 标记任务为 running
|
||||
_update_task_status(task_id, "mark_processing")
|
||||
_update_task_progress(task_id, 10, "任务启动")
|
||||
|
||||
try:
|
||||
editing_mode = EditingMode(mode) if (mode := task_info["mode"]) else EditingMode.ONE_TAKE
|
||||
@@ -1316,7 +1353,10 @@ def generate_video(self, task_id: str) -> dict:
|
||||
)
|
||||
_flush_logs(task_id, gen_task)
|
||||
|
||||
_update_task_progress(task_id, 30, "素材下载完成")
|
||||
|
||||
# ── 3. 渲染 + 混音 ───────────────────────────────────────────────
|
||||
_update_task_progress(task_id, 40, "开始渲染")
|
||||
output_path, render_duration = _render_video(
|
||||
task_id=task_id,
|
||||
downloaded_videos=downloaded_videos,
|
||||
@@ -1336,7 +1376,10 @@ def generate_video(self, task_id: str) -> dict:
|
||||
gen_task.append_log("渲染", f"渲染完成, 时长={render_duration:.1f}s")
|
||||
_flush_logs(task_id, gen_task)
|
||||
|
||||
_update_task_progress(task_id, 80, "渲染完成")
|
||||
|
||||
# ── 4. 上传 OSS + 查重记录 ───────────────────────────────────────
|
||||
_update_task_progress(task_id, 85, "开始上传")
|
||||
file_url, duration, file_size, video_count = _upload_and_record(
|
||||
task_id=task_id,
|
||||
output_path=output_path,
|
||||
@@ -1356,6 +1399,8 @@ def generate_video(self, task_id: str) -> dict:
|
||||
)
|
||||
_flush_logs(task_id, gen_task)
|
||||
|
||||
_update_task_progress(task_id, 95, "上传完成")
|
||||
|
||||
# ── 5. 标记完成 ──────────────────────────────────────────────────
|
||||
_update_task_status(task_id, "mark_completed", result_count=video_count)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user