-
Notifications
You must be signed in to change notification settings - Fork 174
/
settings.py
66 lines (48 loc) · 1.74 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from typing import List, Optional
from pydantic import BaseSettings, PyObject
from .version import __version__
from .types import MetadataTensor
ENV_PREFIX_SETTINGS = "MLSERVER_"
ENV_PREFIX_MODEL_SETTINGS = "MLSERVER_MODEL_"
class Settings(BaseSettings):
class Config:
env_prefix = ENV_PREFIX_SETTINGS
debug: bool = True
# Model repository folder
model_repository_root: str = "."
load_models_at_startup: bool = True
# Server metadata
server_name: str = "mlserver"
server_version: str = __version__
extensions: List[str] = []
# Server settings
host: str = "0.0.0.0"
http_port: int = 8080
grpc_port: int = 8081
grpc_workers: int = 10
class ModelParameters(BaseSettings):
"""
Parameters that apply only to a particular instance of a model.
This can include things like model weights.
The main difference with respect to ModelSettings is that parameters can
change on each instance (e.g. each version) of the model.
"""
class Config:
env_prefix = ENV_PREFIX_MODEL_SETTINGS
uri: Optional[str] = None
version: Optional[str] = None
format: Optional[str] = None
class ModelSettings(BaseSettings):
class Config:
env_prefix = ENV_PREFIX_MODEL_SETTINGS
name: str = ""
# Model metadata
platform: str = ""
versions: Optional[List[str]] = []
inputs: Optional[List[MetadataTensor]] = []
outputs: Optional[List[MetadataTensor]] = []
# Custom model class implementation
implementation: PyObject = "mlserver.model.MLModel" # type: ignore
# Model parameters are meant to be set directly by the MLServer runtime.
# However, it's also possible to override them manually.
parameters: Optional[ModelParameters] = None