Skip to content

Configuration - environment variables

You can set different values for paths of respo generated files using environment variables below. Note, config settings instance is created on import, you don't have to set env variables, but also

1
2
3
4
5
6
from respo import config

config.RESPO_AUTO_FOLDER_NAME = "/opt/some_folder"

(...)
# other respo code after it

respo.settings

Config

Bases: pydantic.BaseSettings

Config for respo based on evironment variables.

Parameters:

Name Type Description Default
RESPO_AUTO_FOLDER_NAME str

folder with pickled respo model

required
RESPO_AUTO_BINARY_FILE_NAME str

file name of pickled model in auto folder

required
RESPO_CHECK_FORCE bool

require strict validation in respo.RespoClient methods

required
RESPO_FILE_NAME_RESPO_MODEL str

name of exported python file

required
Source code in respo/settings.py
 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
class Config(pydantic.BaseSettings):
    """Config for respo based on evironment variables.

    Args:
        RESPO_AUTO_FOLDER_NAME (str): folder with pickled respo model
        RESPO_AUTO_BINARY_FILE_NAME (str): file name of pickled model in auto folder
        RESPO_CHECK_FORCE (bool): require strict validation in respo.RespoClient methods
        RESPO_FILE_NAME_RESPO_MODEL (str): name of exported python file
    """

    RESPO_AUTO_FOLDER_NAME: str = ".respo_cache"
    RESPO_AUTO_BINARY_FILE_NAME: str = "__auto__respo_model.bin"

    RESPO_CHECK_FORCE: bool = True
    RESPO_FILE_NAME_RESPO_MODEL: str = "respo_model.py"

    @property
    def path_bin_file(self):
        """Get pathlib path to binary file"""
        return pathlib.Path(
            f"{self.RESPO_AUTO_FOLDER_NAME}/{self.RESPO_AUTO_BINARY_FILE_NAME}"
        )

    @property
    def path_python_file(self):
        """Get pathlib path to respo python file"""
        return pathlib.Path(self.RESPO_FILE_NAME_RESPO_MODEL)

path_bin_file() property

Get pathlib path to binary file

Source code in respo/settings.py
22
23
24
25
26
27
@property
def path_bin_file(self):
    """Get pathlib path to binary file"""
    return pathlib.Path(
        f"{self.RESPO_AUTO_FOLDER_NAME}/{self.RESPO_AUTO_BINARY_FILE_NAME}"
    )

path_python_file() property

Get pathlib path to respo python file

Source code in respo/settings.py
29
30
31
32
@property
def path_python_file(self):
    """Get pathlib path to respo python file"""
    return pathlib.Path(self.RESPO_FILE_NAME_RESPO_MODEL)