chore: 清理 generation.py 中未使用的渲染函数和常量 #1413

Merged
xiaoxia merged 3 commits from cleanup/remove-dead-render-code into develop 2026-08-18 11:28:15 +08:00
Owner

改动

删除 generation.py 中已废弃的 FFmpeg 渲染辅助函数(已被 RenderAdapter 统一渲染路径替代):

删除的函数

  • _create_fallback_clip — 无素材时创建 fallback 视频(FFmpeg drawtext)
  • _mux_audio_track — 后处理混音(视频+音频合并)
  • _prepare_bgm_track — BGM 下载与准备(URL/素材库/预设库三级查找)

这 3 个函数在 RenderAdapter 重构后已无任何调用方。

删除的常量/导入

  • OUTPUT_DURATION_SECONDS = 5.0
  • GENERATED_FILES_DIR = Path(os.getenv(...))
  • from video_processing.ffmpeg_utils import FFMPEG_BIN, run_ffmpeg
  • import os

清理量

  • 共删除 158 行代码
  • 无新增代码

验证

  • 116 个 generation 相关单元测试全部通过
  • 不影响 generate_video Celery 任务的正常运行(该任务使用 _render_videoRenderAdapter 路径)
## 改动 删除 `generation.py` 中已废弃的 FFmpeg 渲染辅助函数(已被 RenderAdapter 统一渲染路径替代): ### 删除的函数 - **`_create_fallback_clip`** — 无素材时创建 fallback 视频(FFmpeg drawtext) - **`_mux_audio_track`** — 后处理混音(视频+音频合并) - **`_prepare_bgm_track`** — BGM 下载与准备(URL/素材库/预设库三级查找) 这 3 个函数在 RenderAdapter 重构后已无任何调用方。 ### 删除的常量/导入 - `OUTPUT_DURATION_SECONDS = 5.0` - `GENERATED_FILES_DIR = Path(os.getenv(...))` - `from video_processing.ffmpeg_utils import FFMPEG_BIN, run_ffmpeg` - `import os` ### 清理量 - 共删除 158 行代码 - 无新增代码 ### 验证 - 116 个 generation 相关单元测试全部通过 - 不影响 `generate_video` Celery 任务的正常运行(该任务使用 `_render_video` → `RenderAdapter` 路径)

🚀 预览环境已部署

项目 详情
PR号 #1413
预览链接 https://pr-1413.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1413 | | 预览链接 | [https://pr-1413.preview.xiaoxiajianji.com](https://pr-1413.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot approved these changes 2026-08-18 00:55:30 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-08-18 00:55:30 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
xiaoxia added 1 commit 2026-08-18 11:06:32 +08:00
chore: 清理 generation.py 中未使用的渲染函数和常量
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Failing after 0s
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Failing after 0s
PR Automation / Auto Approve on CI Green (pull_request) Failing after 1s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Failing after 0s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 0s
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 11s
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 (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Failing after 0s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m19s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m23s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 5m27s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 6m49s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 2m27s
CI/CD Pipeline / CI Gate (pull_request) Failing after 10s
30804f956b
删除已废弃的 FFmpeg 渲染辅助函数(已被 RenderAdapter 统一路径替代):
- _create_fallback_clip: 无素材时创建 fallback 视频
- _mux_audio_track: 后处理混音(视频+音频合并)
- _prepare_bgm_track: BGM 下载与准备

同时清理相关的未使用常量:
- OUTPUT_DURATION_SECONDS
- GENERATED_FILES_DIR
- FFMPEG_BIN, run_ffmpeg (from video_processing.ffmpeg_utils)
- import os
xiaoxia force-pushed cleanup/remove-dead-render-code from fef61ef071 to 30804f956b 2026-08-18 11:06:32 +08:00 Compare
xiaoxia added 1 commit 2026-08-18 11:19:17 +08:00
fix: 清理 test_full_pipeline.py 中对已删除函数的引用
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (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 59s
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 (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m45s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m57s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m59s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 2m32s
CI/CD Pipeline / Validate - Code Quality (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 API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (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
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Successful in 1m53s
ef6a1bda79
- 移除 _create_fallback_clip、_mux_audio_track 的 import
- 删除 TestFallbackClip、TestMuxAudioTrack 测试类
- TestFullPipeline 中的混音改用直接 ffmpeg 命令
auto-approve-bot added 1 commit 2026-08-18 11:23:11 +08:00
style: auto-format with black + isort + prettier [skip ci-format-check]
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
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 1m1s
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 (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m49s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m53s
AI Code Review / AI Code Review (pull_request) Successful in 2m9s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 2m12s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 2m19s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 4m40s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m54s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 46s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 54s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 7m56s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 7m5s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m46s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 14m59s
CI/CD Pipeline / CI Gate (pull_request) Successful in 7s
e5e46bb02b
xiaoxia merged commit abb8e0fcaf into develop 2026-08-18 11:28:15 +08:00
xiaoxia deleted branch cleanup/remove-dead-render-code 2026-08-18 11:28:15 +08:00

🗑️ 预览环境已清理

PR #1413 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1413 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Collaborator

【阻塞级判定】

  • 是否存在阻塞级问题:否
  • 阻塞级问题数量:0 个

📊 审查概览

  • 整体评价:通过
  • 建议级问题数量:2 个

🔴 阻塞级问题(必须修复)

💡 改进建议(不阻塞合并)

  1. [apps/worker/worker_app/tasks/generation.py:39-40] 常量移除的影响范围确认

    • 具体内容:代码中移除了 OUTPUT_DURATION_SECONDSGENERATED_FILES_DIR 两个常量。虽然被引用的函数 _create_fallback_clip 也被移除了,但请确认这两个常量是否被项目中的其他模块(通过 from worker_app.tasks.generation import ...)引用。如果有外部引用,会导致引用方报错。
  2. [tests/integration/test_full_pipeline.py:119-143] 测试代码中的 FFmpeg 命令差异

    • 具体内容:在 test_full_pipeline_with_audio 中,手动构造的 ffmpeg 命令移除了原函数 _mux_audio_track 中的 -map 0:v:0 -map 1:a:0 参数。虽然如果输入流规整通常不会报错,但显式指定 -map 是更健壮的做法,能避免因输入文件包含多流而导致的意外行为。建议补充 -map 参数以保持与原逻辑一致的严谨性。

良好实践

  • 代码清理彻底,移除了不再使用的导入(os, FFMPEG_BIN, run_ffmpeg),避免了死代码。
  • 测试文件及时同步更新,移除了针对已删除函数的测试类,保持了测试套件的整洁。
  • 测试中使用了 subprocess.run 替代被删除的内部函数,保证了集成测试链路的完整性。

格式检查通过 | 逻辑审查通过 | 性能良好


🤖 由 AI 代码审查机器人自动生成 | 2026-08-18 03:29:24 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:通过 - 建议级问题数量:2 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 1. **[apps/worker/worker_app/tasks/generation.py:39-40] 常量移除的影响范围确认** - 具体内容:代码中移除了 `OUTPUT_DURATION_SECONDS` 和 `GENERATED_FILES_DIR` 两个常量。虽然被引用的函数 `_create_fallback_clip` 也被移除了,但请确认这两个常量是否被项目中的其他模块(通过 `from worker_app.tasks.generation import ...`)引用。如果有外部引用,会导致引用方报错。 2. **[tests/integration/test_full_pipeline.py:119-143] 测试代码中的 FFmpeg 命令差异** - 具体内容:在 `test_full_pipeline_with_audio` 中,手动构造的 `ffmpeg` 命令移除了原函数 `_mux_audio_track` 中的 `-map 0:v:0 -map 1:a:0` 参数。虽然如果输入流规整通常不会报错,但显式指定 `-map` 是更健壮的做法,能避免因输入文件包含多流而导致的意外行为。建议补充 `-map` 参数以保持与原逻辑一致的严谨性。 ### ✅ 良好实践 - 代码清理彻底,移除了不再使用的导入(`os`, `FFMPEG_BIN`, `run_ffmpeg`),避免了死代码。 - 测试文件及时同步更新,移除了针对已删除函数的测试类,保持了测试套件的整洁。 - 测试中使用了 `subprocess.run` 替代被删除的内部函数,保证了集成测试链路的完整性。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能良好 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-08-18 03:29:24 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
Sign in to join this conversation.