fix: 修正模型超时与结果未知重放
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""只读预览或恢复被旧成片硬超时误判失败的视频任务。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from apps.ai.video_timeout_recovery import reconcile_video_timeout_task
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "核对旧 generation_timeout 误判的视频任务;默认只读,--apply 才恢复远端成功结果"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"--task-id",
|
||||
action="append",
|
||||
required=True,
|
||||
help="要核对的 AITask UUID;可重复传入",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--apply",
|
||||
action="store_true",
|
||||
help="仅对远端已 succeeded 的指定任务执行幂等恢复;不会重新提交模型或追扣用户积分",
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
failed = []
|
||||
for task_id in options["task_id"]:
|
||||
try:
|
||||
result = reconcile_video_timeout_task(str(task_id), apply=bool(options["apply"]))
|
||||
except Exception as exc: # noqa: BLE001 — 命令需继续报告同批其他显式任务
|
||||
failed.append(f"{task_id}: {exc}")
|
||||
self.stderr.write(self.style.ERROR(f"{task_id}: {exc}"))
|
||||
continue
|
||||
self.stdout.write(json.dumps(result, ensure_ascii=False, default=str, sort_keys=True))
|
||||
if failed:
|
||||
raise CommandError(";".join(failed))
|
||||
Reference in New Issue
Block a user