利用 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(skill): finalize manifest when generation cannot start
Rudy Celekli1528b0eb757a
diff --git a/docs/skill/mpt_agent.py b/docs/skill/mpt_agent.pyindex 121caf14..6522fd30 100644--- a/docs/skill/mpt_agent.py+++ b/docs/skill/mpt_agent.py@@ -730,15 +730,31 @@ def generate_video(]log(f"starting video generation, task ID: {task_id}")log(f"full generation log: {log_path}")- with log_path.open("w", encoding="utf-8") as log_file:- result = subprocess.run(- command,- cwd=root,- stdout=log_file,- stderr=subprocess.STDOUT,- text=True,- check=False,+ try:+ with log_path.open("w", encoding="utf-8") as log_file:+ result = subprocess.run(+ command,+ cwd=root,+ stdout=log_file,+ stderr=subprocess.STDOUT,+ text=True,+ check=False,+ )+ except OSError as exc:+ error = f"video generation could not start: {exc}; log: {log_path}"+ write_result_manifest(+ root,+ {+ "status": "failed",+ "subject": subject,+ "task_id": task_id,+ "task_dir": str(task_dir.resolve()),+ "log_file": str(log_path.resolve()),+ "video_files": [],+ "error": error,+ },)+ raise SkillError(error) from excif result.returncode != 0:tail = log_path.read_text(encoding="utf-8", errors="replace").splitlines()[-30:]if tail:diff --git a/test/services/test_skill_spawn_failure_manifest.py b/test/services/test_skill_spawn_failure_manifest.pynew file mode 100644index 00000000..fdf5302b--- /dev/null+++ b/test/services/test_skill_spawn_failure_manifest.py@@ -0,0 +1,23 @@+import importlib.util+import json+from pathlib import Path+from unittest.mock import patch++import pytest+++spec = importlib.util.spec_from_file_location("mpt_agent_spawn_manifest", Path(__file__).resolve().parents[2] / "docs/skill/mpt_agent.py")+agent = importlib.util.module_from_spec(spec)+spec.loader.exec_module(agent)+++def test_actual_process_start_failure_records_terminal_manifest(tmp_path):+ missing_executable = str(tmp_path / "removed-uv")+ with patch.object(agent.shutil, "which", return_value=missing_executable), patch.object(agent, "run_checked"):+ with pytest.raises((OSError, agent.SkillError)):+ agent.generate_video(tmp_path, "fixture subject", [])+ payload = json.loads(agent.result_manifest_path(tmp_path).read_text())+ assert payload["status"] == "failed"+ assert payload["video_files"] == []+ assert payload["task_id"] and payload["log_file"]+ assert "start" in payload["error"]