"""Pydantic models for data-related type tables (DataFileType, ConfigFileType, etc.)."""
from typing import ClassVar
from pydantic import BaseModel, ConfigDict, Field
[docs]
class DataFileTypeBase(BaseModel):
"""Model for a type of file that contains data."""
[docs]
name: str = Field(..., description="Name of the data file type")
[docs]
class DataFileTypeCreate(DataFileTypeBase):
"""Fields used to create a DataFileType."""
[docs]
class DataFileType(DataFileTypeBase):
"""DataFileType response model."""
[docs]
model_config = ConfigDict(from_attributes=True)
[docs]
col_names_for_table: ClassVar[list[str]] = ["id_", "name"]
[docs]
id_: int = Field(..., gt=0)
[docs]
class ConfigFileTypeBase(BaseModel):
"""Model for a type of file that contains configuration."""
[docs]
name: str = Field(..., description="Name of the config file type")
[docs]
class ConfigFileTypeCreate(ConfigFileTypeBase):
"""Fields used to create a ConfigFileType."""
[docs]
class ConfigFileType(ConfigFileTypeBase):
"""ConfigFileType response model."""
[docs]
model_config = ConfigDict(from_attributes=True)
[docs]
col_names_for_table: ClassVar[list[str]] = ["id_", "name"]
[docs]
id_: int = Field(..., gt=0)
[docs]
class ConfigDictTypeBase(BaseModel):
"""Model for a type of dict that contains configuration."""
[docs]
name: str = Field(..., description="Name of the config dict type")
[docs]
class ConfigDictTypeCreate(ConfigDictTypeBase):
"""Fields used to create a ConfigDictType."""
[docs]
class ConfigDictType(ConfigDictTypeBase):
"""ConfigDictType response model."""
[docs]
model_config = ConfigDict(from_attributes=True)
[docs]
col_names_for_table: ClassVar[list[str]] = ["id_", "name"]
[docs]
id_: int = Field(..., gt=0)
[docs]
class ParameterBase(BaseModel):
"""Model for a parameter definition."""
[docs]
name: str = Field(..., description="Name of the parameter")
[docs]
class ParameterCreate(ParameterBase):
"""Fields used to create a Parameter."""
[docs]
class Parameter(ParameterBase):
"""Parameter response model."""
[docs]
model_config = ConfigDict(from_attributes=True)
[docs]
col_names_for_table: ClassVar[list[str]] = ["id_", "name"]
[docs]
id_: int = Field(..., gt=0)
[docs]
class ArrayBase(BaseModel):
"""Model for an array definition."""
[docs]
name: str = Field(..., description="Name of the array")
[docs]
n_dim: int = Field(..., description="Number of dimensions")
[docs]
shape: list[int] = Field(..., description="Shape of the array")
[docs]
class ArrayCreate(ArrayBase):
"""Fields used to create an Array."""
[docs]
class Array(ArrayBase):
"""Array response model."""
[docs]
model_config = ConfigDict(from_attributes=True)
[docs]
col_names_for_table: ClassVar[list[str]] = ["id_", "name", "n_dim", "shape"]
[docs]
id_: int = Field(..., gt=0)
[docs]
class ClassBase(BaseModel):
"""Model for a Python class definition."""
[docs]
name: str = Field(..., description="Name of the class")
[docs]
module_: str = Field(..., description="Python module where it lives")
[docs]
class ClassCreate(ClassBase):
"""Fields used to create a Class."""
[docs]
class Class(ClassBase):
"""Class response model."""
[docs]
model_config = ConfigDict(from_attributes=True)
[docs]
col_names_for_table: ClassVar[list[str]] = ["id_", "name", "module_"]
[docs]
id_: int = Field(..., gt=0)