Source code for chap_core.external.model_configuration
from typing import Optional
from pydantic import BaseModel
from chap_core.database.model_templates_and_config_tables import ModelTemplateMetaData, ModelTemplateInformation
[docs]
class DockerEnvConfig(BaseModel):
image: str
[docs]
class CommandConfig(BaseModel):
command: str
parameters: Optional[dict[str, str]] = None
[docs]
class EntryPointConfig(BaseModel):
train: CommandConfig
predict: CommandConfig
[docs]
class RunnerConfig(BaseModel, extra="forbid"): # pydantic-specific config to forbid extra fields):
"""This is all needed to actually run model"""
entry_points: Optional[EntryPointConfig] = None
docker_env: Optional[DockerEnvConfig] = None
python_env: Optional[str] = None
[docs]
class ModelTemplateConfigCommon(ModelTemplateInformation, extra="forbid"):
meta_data: ModelTemplateMetaData = ModelTemplateMetaData()
# TODO: maybe rename to ModelTemplateYamlConfig
[docs]
class ModelTemplateConfigV2(ModelTemplateConfigCommon, RunnerConfig, extra="forbid"):
"""This is used to parse MLProject files"""
name: str
source_url: Optional[str] = None
adapters: Optional[dict[str, str]] = None
rest_api_url: Optional[str] = None
version: Optional[str] = None