#!/usr/bin/python
# -*- coding: utf-8 -*-
# @version        : 1.0
# @Create Time    : 2025/04/03 10:32
# @File           : project_train.py
# @IDE            : PyCharm
# @desc           : pydantic 模型，用于数据库序列化操作

from core.data_types import DatetimeStr

from pydantic import BaseModel, Field, ConfigDict
from typing import Optional

"""
项目训练版本信息表
"""


class ProjectTrainIn(BaseModel):
    project_id: Optional[int] = Field(..., description="项目id")
    weights_id: Optional[int] = Field(None, description="权重文件")
    weights_name: Optional[str] = Field(None, description="权重文件名称")
    epochs: Optional[int] = Field(50, description="训练轮数")
    patience: Optional[int] = Field(20, description="早停的耐心值")


class ProjectTrainOut(BaseModel):
    id: Optional[int] = Field(None, description="训练id")
    train_version: Optional[str] = Field(None, description="训练版本号")
    weights_name: Optional[str] = Field(None, description="权重名称")
    epochs: Optional[int] = Field(None, description="训练轮数")
    patience: Optional[int] = Field(None, description="早停的耐心值")
    create_datetime: DatetimeStr

    model_config = ConfigDict(from_attributes=True)

