f988a028fe
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 29s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (web-cache, infra/docker/web.Dockerfile, xiaoxia-saas-web, web, Web, 30) (pull_request) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Failing after 34s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 38s
CI/CD Pipeline / PR Build API Image (Backend) (pull_request) Successful in 1m21s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / AI Code Review (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (Backend) (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
- 新增 ConfirmGenerationRequest schema 和 POST /tasks/{task_id}/confirm 端点
- 确认生成复用 worker.generate_video 完整渲染路径(不再走 edit_plan_generation.py)
- 默认分辨率 1080x1920(竖屏),支持自定义封面和标题
- 新增字段: is_preview, source_task_id, output_width, output_height, cover_url, custom_title
- 贯穿 Schema → Domain → Application → DB Model → Repository → Worker 全链路
- 更新 task_center.py 和 generation_tasks.py 的重试逻辑传递新字段
- Alembic 迁移 034: 为 generation_tasks 表添加 6 个新列
- 7 个单元测试覆盖确认生成的正常/异常流程
- 使用 getattr 带默认值确保向后兼容
104 lines
3.3 KiB
Python
104 lines
3.3 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime, timezone
|
|
|
|
if sys.version_info >= (3, 11):
|
|
from enum import StrEnum
|
|
else:
|
|
from enum import Enum
|
|
|
|
class StrEnum(str, Enum):
|
|
pass
|
|
|
|
|
|
from uuid import uuid4
|
|
|
|
|
|
class GenerationTaskStatus(StrEnum):
|
|
PENDING = "pending"
|
|
RUNNING = "running"
|
|
COMPLETED = "completed"
|
|
FAILED = "failed"
|
|
CANCELLED = "cancelled"
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class GenerationTask:
|
|
id: str
|
|
project_id: str
|
|
asset_library_id: str
|
|
strategy_id: str = ""
|
|
voice_library_id: str = ""
|
|
template_id: str = ""
|
|
asset_ids: list[str] = field(default_factory=list)
|
|
title_ids: list[str] = field(default_factory=list)
|
|
voice_ids: list[str] = field(default_factory=list)
|
|
status: GenerationTaskStatus = GenerationTaskStatus.PENDING
|
|
progress: float = 0.0
|
|
result_count: int = 0
|
|
error_message: str = ""
|
|
started_at: datetime | None = None
|
|
completed_at: datetime | None = None
|
|
source_edit_plan_id: str = ""
|
|
created_by_user_id: str = ""
|
|
asset_select_mode: str = ""
|
|
batch_id: str = ""
|
|
is_preview: bool = True
|
|
source_task_id: str = ""
|
|
output_width: int = 1280
|
|
output_height: int = 720
|
|
cover_url: str = ""
|
|
custom_title: str = ""
|
|
created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
|
|
|
@classmethod
|
|
def create(
|
|
cls,
|
|
project_id: str,
|
|
asset_library_id: str,
|
|
*,
|
|
strategy_id: str = "",
|
|
voice_library_id: str = "",
|
|
template_id: str = "",
|
|
asset_ids: list[str] | None = None,
|
|
title_ids: list[str] | None = None,
|
|
voice_ids: list[str] | None = None,
|
|
created_by_user_id: str = "",
|
|
source_edit_plan_id: str = "",
|
|
asset_select_mode: str = "",
|
|
batch_id: str = "",
|
|
is_preview: bool = True,
|
|
source_task_id: str = "",
|
|
output_width: int = 1280,
|
|
output_height: int = 720,
|
|
cover_url: str = "",
|
|
custom_title: str = "",
|
|
) -> "GenerationTask":
|
|
if not project_id.strip() and not template_id.strip():
|
|
raise ValueError("project_id 或 template_id 至少需要提供一个")
|
|
if not asset_library_id.strip() and not (asset_ids or title_ids or voice_ids):
|
|
raise ValueError("asset_library_id 或 asset_ids/title_ids/voice_ids 至少需要提供一个")
|
|
return cls(
|
|
id=uuid4().hex,
|
|
project_id=project_id.strip(),
|
|
asset_library_id=asset_library_id.strip(),
|
|
strategy_id=strategy_id.strip(),
|
|
voice_library_id=voice_library_id.strip(),
|
|
template_id=template_id.strip(),
|
|
asset_ids=list(asset_ids) if asset_ids else [],
|
|
title_ids=list(title_ids) if title_ids else [],
|
|
voice_ids=list(voice_ids) if voice_ids else [],
|
|
created_by_user_id=created_by_user_id.strip(),
|
|
source_edit_plan_id=source_edit_plan_id.strip(),
|
|
asset_select_mode=asset_select_mode,
|
|
batch_id=batch_id,
|
|
is_preview=is_preview,
|
|
source_task_id=source_task_id,
|
|
output_width=output_width,
|
|
output_height=output_height,
|
|
cover_url=cover_url,
|
|
custom_title=custom_title,
|
|
)
|