Skip to content

config

zeus.optimizer.batch_size.server.config

Server global configurations.

ZeusBsoSettings

Bases: BaseSettings

App setting.

Attributes:

Name Type Description
database_url str

url of database for the server

echo_sql Union[bool, str]

log sql statements it executes

log_level str

level of log

Source code in zeus/optimizer/batch_size/server/config.py
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
class ZeusBsoSettings(BaseSettings):
    """App setting.

    Attributes:
        database_url: url of database for the server
        echo_sql: log sql statements it executes
        log_level: level of log
    """

    database_url: str
    echo_sql: Union[bool, str] = False  # To prevent conversion error for empty string
    log_level: str = "INFO"

    class Config:  # type: ignore
        """Model configuration.

        Set how to find the env variables and how to parse it.
        """

        env_prefix = "ZEUS_BSO_"
        env_file = find_dotenv(filename=".env")
        env_file_encoding = "utf-8"

    @validator("echo_sql")
    def _validate_echo_sql(cls, v) -> bool:
        if v is not None and isinstance(v, bool):
            return v
        elif v is not None and isinstance(v, str):
            if v.lower() == "false":
                return False
            elif v.lower() == "true":
                return True
        return False

    @validator("log_level")
    def _validate_log_level(cls, v) -> str:
        if v is None or v not in {
            "NOTSET",
            "DEBUG",
            "INFO",
            "WARN",
            "ERROR",
            "CRITICAL",
        }:
            # Default log level
            return "INFO"
        return v

Config

Model configuration.

Set how to find the env variables and how to parse it.

Source code in zeus/optimizer/batch_size/server/config.py
23
24
25
26
27
28
29
30
31
class Config:  # type: ignore
    """Model configuration.

    Set how to find the env variables and how to parse it.
    """

    env_prefix = "ZEUS_BSO_"
    env_file = find_dotenv(filename=".env")
    env_file_encoding = "utf-8"