from datetime import datetime, timezone
from typing import ClassVar, Optional
from uuid import UUID, uuid4

from sqlmodel import Field, SQLModel


class SubTaskRow(SQLModel, table=True):
    __tablename__: ClassVar[str] = "sub_task"  # pyright: ignore[reportIncompatibleVariableOverride]

    id: UUID = Field(default_factory=uuid4, primary_key=True, index=True)
    task_id: UUID = Field(foreign_key="tasks.id")
    job_started: Optional[datetime] = None
    job_completed: Optional[datetime] = None
    status: str = Field(default="waiting")
    inputs: Optional[str] = None
    outputs: Optional[str] = None
    cloud_logs_url: Optional[str] = None
    updated_at: datetime = Field(
        default_factory=lambda: datetime.now(timezone.utc)
    )
