68 lines
1.5 KiB
Python
68 lines
1.5 KiB
Python
"""Job schema — source of truth for pipeline jobs."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
from typing import Any, Dict, Optional
|
|
from uuid import UUID
|
|
|
|
|
|
class JobStatus(str, Enum):
|
|
PENDING = "pending"
|
|
RUNNING = "running"
|
|
PAUSED = "paused"
|
|
COMPLETED = "completed"
|
|
FAILED = "failed"
|
|
CANCELLED = "cancelled"
|
|
|
|
|
|
class RunType(str, Enum):
|
|
INITIAL = "initial"
|
|
REPLAY = "replay"
|
|
RETRY = "retry"
|
|
|
|
|
|
@dataclass
|
|
class Job:
|
|
"""
|
|
A pipeline job.
|
|
|
|
Each invocation (initial run, replay, retry) creates a Job.
|
|
Jobs for the same source are linked via parent_id.
|
|
"""
|
|
|
|
id: UUID
|
|
|
|
# Input
|
|
source_asset_id: UUID
|
|
video_path: str
|
|
profile_name: str = "soccer_broadcast"
|
|
|
|
# Timeline — set after frame extraction, or upfront for replay jobs
|
|
timeline_id: Optional[UUID] = None
|
|
|
|
# Lineage
|
|
parent_id: Optional[UUID] = None
|
|
run_type: RunType = RunType.INITIAL
|
|
config_overrides: Dict[str, Any] = field(default_factory=dict)
|
|
|
|
# Status
|
|
status: JobStatus = JobStatus.PENDING
|
|
current_stage: Optional[str] = None
|
|
progress: float = 0.0
|
|
error_message: Optional[str] = None
|
|
|
|
# Results summary
|
|
total_detections: int = 0
|
|
brands_found: int = 0
|
|
cloud_llm_calls: int = 0
|
|
estimated_cost_usd: float = 0.0
|
|
|
|
# Worker tracking
|
|
priority: int = 0
|
|
|
|
# Timestamps
|
|
created_at: Optional[datetime] = None
|
|
started_at: Optional[datetime] = None
|
|
completed_at: Optional[datetime] = None
|