fix(api): use celery_app.send_task() for viral_video enqueue instead of direct worker import
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 3s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
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 / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped 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 / PR Build API Image (pull_request) Successful in 56s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m18s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m5s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 3m17s
AI Code Review / AI Code Review (pull_request) Successful in 6m8s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 8m11s
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
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 5m46s

The viral_video API route module had 4 places that did
`from worker_app.tasks.viral_video import <task>` and then <task>.delay().
In the API container the worker_app package is not installed, so calling
generate/retry/confirm-intent/analyze-style would raise ModuleNotFoundError:
No module named 'worker_app'.

Switched all four call sites to celery_app.send_task() string-dispatch
(matches the existing pattern in app/core/task_enqueue.py for
worker.generate_video). Verified task names match @shared_task(name=...)
declared in worker_app/tasks/viral_video.py:
  - worker.run_viral_video_pipeline
  - worker.resume_viral_video_pipeline
  - worker.run_video_style_analysis
This commit is contained in:
xiaoxia
2026-09-30 15:30:36 +08:00
parent bf9249da19
commit f7f600d091
+5 -12
View File
@@ -34,6 +34,7 @@ from packages.adapters.sqlalchemy_impl.viral_video_repository import (
SQLAlchemyViralVideoJobRepository,
SQLAlchemyViralVideoStyleTemplateRepository,
)
from app.core.celery_app import celery_app
from packages.domain.viral_video import ViralVideoStatus
logger = logging.getLogger(__name__)
@@ -122,9 +123,7 @@ def create_viral_video(
# 入队 Celery 任务
try:
from worker_app.tasks.viral_video import run_viral_video_pipeline
run_viral_video_pipeline.delay(job.id)
celery_app.send_task("worker.run_viral_video_pipeline", args=[job.id])
logger.info("[爆款视频] 任务已入队: job_id=%s user_id=%s", job.id, job.user_id)
except Exception as e:
logger.error("[爆款视频] 入队失败: %s", e, exc_info=True)
@@ -210,9 +209,7 @@ def retry_viral_video_job(
# 重新入队
try:
from worker_app.tasks.viral_video import run_viral_video_pipeline
run_viral_video_pipeline.delay(job.id)
celery_app.send_task("worker.run_viral_video_pipeline", args=[job.id])
logger.info("[爆款视频] 重试入队: job_id=%s retry_count=%d", job.id, job.retry_count)
except Exception as e:
logger.error("[爆款视频] 重试入队失败: %s", e, exc_info=True)
@@ -249,9 +246,7 @@ def confirm_intent(
# 从断点恢复 Celery 任务
try:
from worker_app.tasks.viral_video import resume_viral_video_pipeline
resume_viral_video_pipeline.delay(job.id)
celery_app.send_task("worker.resume_viral_video_pipeline", args=[job.id])
logger.info("[爆款视频] 意图确认,恢复流水线: job_id=%s", job.id)
except Exception as e:
logger.error("[爆款视频] 恢复流水线失败: %s", e, exc_info=True)
@@ -284,9 +279,7 @@ def analyze_style(
# 入队风格分析任务
try:
from worker_app.tasks.viral_video import run_video_style_analysis
run_video_style_analysis.delay(job.id)
celery_app.send_task("worker.run_video_style_analysis", args=[job.id])
logger.info("[爆款视频] 风格分析入队: job_id=%s", job.id)
except Exception as e:
logger.error("[爆款视频] 风格分析入队失败: %s", e, exc_info=True)