from typing import Optional

from sqlmodel import SQLModel, Field

from entity.base import TimestampMixin


class AlgoModelBase(SQLModel):
    name: str
    version: str
    path: str
    handle_task: Optional[str] = None
    remark: Optional[str] = None


class AlgoModel(AlgoModelBase, TimestampMixin, table=True):
    __tablename__ = "algo_model"  # 显式指定表名

    id: Optional[int] = Field(default=None, primary_key=True)


class AlgoModelCreate(AlgoModelBase):
    path: Optional[str] = None


class AlgoModelUpdate(AlgoModelBase):
    id: int
    name: Optional[str] = None
    version: Optional[str] = None
    path: Optional[str] = None


class AlgoModelInfo(AlgoModelBase, TimestampMixin):
    id: int
    usage_status: Optional[str] = None
    handle_task: Optional[str] = 'BaseModelHandler'
