利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(task): clear stale failure diagnostics when retrying a task
Rudy Celekli11b92c516a06
diff --git a/app/services/task.py b/app/services/task.pyindex 08a586d0..98fa7d52 100644--- a/app/services/task.py+++ b/app/services/task.py@@ -1484,7 +1484,10 @@ def _run_pipeline(voxcpm_prompt_text: str = "",):logger.info(f"start task: {task_id}, stop_at: {stop_at}")- sm.state.update_task(task_id, state=const.TASK_STATE_PROCESSING, progress=5)+ sm.state.update_task(+ task_id, state=const.TASK_STATE_PROCESSING, progress=5,+ failed_stage=None, error=None,+ )if stop_at in {"materials", "video"} and params.video_source not in _SUPPORTED_VIDEO_SOURCES:return _mark_task_failed(diff --git a/test/services/test_retry_diagnostics.py b/test/services/test_retry_diagnostics.pynew file mode 100644index 00000000..956646ec--- /dev/null+++ b/test/services/test_retry_diagnostics.py@@ -0,0 +1,61 @@+from unittest.mock import patch+import cli+from app.services import task as tm+from app.services.state import MemoryState+++def test_cli_retry_of_failed_task_id_clears_previous_failure_diagnostics(capsys):+ state = MemoryState()+ state.update_task(+ "00000000-0000-4000-8000-000000000001",+ state=tm.const.TASK_STATE_FAILED,+ failed_stage="audio",+ error="old provider outage",+ video_subject="Coffee",+ )+ with patch.object(tm.sm, "state", state):+ code = cli.run_cli(+ [+ "--task-id",+ "00000000-0000-4000-8000-000000000001",+ "--video-subject",+ "Coffee",+ "--video-script",+ "New narration",+ "--stop-at",+ "script",+ ]+ )+ assert code == 0+ task = state.get_task("00000000-0000-4000-8000-000000000001")+ assert task["state"] == tm.const.TASK_STATE_COMPLETE+ assert task.get("error") is None+ assert task.get("failed_stage") is None+ assert task["video_subject"] == "Coffee"+ assert task["script"] == "New narration"+++def test_new_attempt_clears_diagnostics_before_generating_any_output():+ state = MemoryState()+ state.update_task(+ "00000000-0000-4000-8000-000000000001",+ state=tm.const.TASK_STATE_FAILED,+ failed_stage="audio",+ error="old provider outage",+ )+ from app.models.schema import VideoParams++ def generate(task_id, params):+ task = state.get_task(task_id)+ assert task.get("error") is None+ assert task.get("failed_stage") is None+ return "New narration"++ with (+ patch.object(tm.sm, "state", state),+ patch.object(tm, "generate_script", side_effect=generate),+ ):+ result = tm.start(+ "00000000-0000-4000-8000-000000000001", VideoParams(video_subject="Coffee"), stop_at="script"+ )+ assert result == {"script": "New narration"}