fix: 剪辑计划P0+P1修复 - asset_ids传递 + result_count修正 + total_duration回写 + logs埋点
CI/CD Pipeline / Production Browser E2E (push) Failing after 1515h7m36s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 1515h7m36s
CI/CD Pipeline / Deploy Production (push) Failing after 1515h7m37s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Failing after 1515h7m37s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Build Staging Worker Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Build Staging API Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Build Production API Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Failing after 1515h39m18s
CI/CD Pipeline / Build Staging Web Image (push) Failing after 1515h39m21s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1515h7m36s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 1515h7m36s
CI/CD Pipeline / Deploy Production (push) Failing after 1515h7m37s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Failing after 1515h7m37s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Build Staging Worker Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Build Staging API Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Build Production API Image (push) Failing after 1515h7m39s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Failing after 1515h39m18s
CI/CD Pipeline / Build Staging Web Image (push) Failing after 1515h39m21s
P0修复: - 触发生成时将plan.config.asset_ids传递到GenerationTask - 同时补全project_id字段(之前为空字符串) P1修复: - result_count: 剪辑计划多片段合成1个成片,改为1(之前误存为clip数) - total_duration: 渲染成功后回写实际输出时长到EditPlan.total_duration - logs: 新增5个关键节点日志埋点(render_start/download_done/download_failed/render_complete/render_failed) - 下载完成后进度推进到30%,便于前端展示素材下载中状态
This commit is contained in:
@@ -253,12 +253,15 @@ def generate_plan(
|
||||
|
||||
gen_task_use_case = CreateGenerationTaskUseCase(gen_task_repo)
|
||||
plan = svc.get_plan_or_raise(plan_id)
|
||||
# 从 plan.config 中读取 asset_ids 并传递给 GenerationTask
|
||||
config_asset_ids = (plan.config or {}).get("asset_ids", [])
|
||||
gen_task = gen_task_use_case.execute(
|
||||
CreateGenerationTaskCommand(
|
||||
project_id="",
|
||||
project_id=plan.project_id or "",
|
||||
template_id=plan.template_id,
|
||||
created_by_user_id=current_user.user.id,
|
||||
source_edit_plan_id=plan_id,
|
||||
asset_ids=list(config_asset_ids) if config_asset_ids else [],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -107,6 +107,14 @@ def _mark_plan_failed(plan_repo, plan_id, gen_task_repo, generation_task_id, err
|
||||
gen_task.status = "failed"
|
||||
gen_task.error_message = error_msg
|
||||
gen_task.completed_at = datetime.now(timezone.utc)
|
||||
try:
|
||||
gen_task.append_log(
|
||||
stage="render_failed",
|
||||
message=error_msg[:500],
|
||||
level="ERROR",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
gen_task_repo.update(gen_task)
|
||||
|
||||
|
||||
@@ -160,9 +168,11 @@ def _finalize_render_success(
|
||||
clip.mark_rendered()
|
||||
clip_repo.update(clip)
|
||||
|
||||
# 更新 EditPlan 状态为 completed
|
||||
# 更新 EditPlan 状态为 completed + 回写实际渲染时长
|
||||
plan.config["rendered_url"] = output_url or ""
|
||||
plan.config["rendered_storage_key"] = storage_key
|
||||
if hasattr(plan, "total_duration") and duration > 0:
|
||||
plan.total_duration = duration
|
||||
plan.mark_completed()
|
||||
plan_repo.update(plan)
|
||||
|
||||
@@ -172,7 +182,15 @@ def _finalize_render_success(
|
||||
if gen_task:
|
||||
gen_task.status = "completed"
|
||||
gen_task.progress = 100.0
|
||||
gen_task.result_count = len(rendered_clip_ids)
|
||||
# 剪辑计划是多片段合成 1 个成片,result_count = 1
|
||||
gen_task.result_count = 1
|
||||
gen_task.append_log(
|
||||
stage="render_complete",
|
||||
message=f"渲染完成,输出时长 {duration:.1f}s",
|
||||
level="INFO",
|
||||
engine=engine,
|
||||
clip_count=len(rendered_clip_ids),
|
||||
)
|
||||
gen_task.completed_at = datetime.now(timezone.utc)
|
||||
gen_task_repo.update(gen_task)
|
||||
|
||||
@@ -377,6 +395,13 @@ def render_edit_plan(self, plan_id: str) -> dict:
|
||||
if gen_task:
|
||||
gen_task.status = "running"
|
||||
gen_task.started_at = datetime.now(timezone.utc)
|
||||
gen_task.append_log(
|
||||
stage="render_start",
|
||||
message=f"开始渲染,引擎 {engine},片段数 {len(clips)}",
|
||||
level="INFO",
|
||||
engine=engine,
|
||||
clip_count=len(clips),
|
||||
)
|
||||
gen_task_repo.update(gen_task)
|
||||
|
||||
# 3. 下载素材并构建 asset_path_map
|
||||
@@ -441,9 +466,28 @@ def render_edit_plan(self, plan_id: str) -> dict:
|
||||
gen_task.status = "failed"
|
||||
gen_task.error_message = "所有片段素材下载失败"
|
||||
gen_task.completed_at = datetime.now(timezone.utc)
|
||||
gen_task.append_log(
|
||||
stage="download_failed",
|
||||
message="所有片段素材下载失败",
|
||||
level="ERROR",
|
||||
)
|
||||
gen_task_repo.update(gen_task)
|
||||
return {"status": "error", "message": "所有片段素材下载失败"}
|
||||
|
||||
# 素材下载完成,记录日志
|
||||
if generation_task_id:
|
||||
gen_task = gen_task_repo.get(generation_task_id)
|
||||
if gen_task:
|
||||
gen_task.append_log(
|
||||
stage="download_done",
|
||||
message=f"素材下载完成,成功 {len(asset_path_map)} 个,失败 {len(failed_clip_ids)} 个",
|
||||
level="INFO",
|
||||
success_count=len(asset_path_map),
|
||||
failed_count=len(failed_clip_ids),
|
||||
)
|
||||
gen_task.progress = 30.0
|
||||
gen_task_repo.update(gen_task)
|
||||
|
||||
# 4. 根据引擎选择渲染方式
|
||||
if engine == "unified":
|
||||
result = _render_with_unified(
|
||||
@@ -495,6 +539,15 @@ def render_edit_plan(self, plan_id: str) -> dict:
|
||||
gen_task.status = "failed"
|
||||
gen_task.error_message = f"渲染异常: {type(exc).__name__}: {exc}"
|
||||
gen_task.completed_at = datetime.now(timezone.utc)
|
||||
try:
|
||||
gen_task.append_log(
|
||||
stage="render_failed",
|
||||
message=f"渲染异常: {type(exc).__name__}: {str(exc)[:500]}",
|
||||
level="ERROR",
|
||||
exception_type=type(exc).__name__,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
gen_task_repo.update(gen_task)
|
||||
logger.info(
|
||||
"GenerationTask 已标记为 failed: task_id=%s plan_id=%s",
|
||||
|
||||
Reference in New Issue
Block a user