25 lines
634 B
Python
25 lines
634 B
Python
import json
|
|
from pathlib import Path
|
|
from typing import Any, Dict
|
|
|
|
|
|
TASK_VIDEO_NAME = "video.mp4"
|
|
TASK_FIRST_FRAME_NAME = "first_frame.jpg"
|
|
TASK_METADATA_NAME = "metadata.json"
|
|
TASK_LOG_NAME = "run.log"
|
|
|
|
|
|
def ensure_dir(path: Path) -> Path:
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
return path
|
|
|
|
|
|
def task_output_dir(base_output_dir: Path, task_id: str) -> Path:
|
|
return ensure_dir(base_output_dir / task_id)
|
|
|
|
|
|
def write_json(path: Path, data: Dict[str, Any]) -> None:
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
with path.open("w", encoding="utf-8") as f:
|
|
json.dump(data, f, ensure_ascii=False, indent=2)
|