Skip to content

lang_tools.params.lang_tools_params

LangTools project params.

Parameters are actual value of the config.

The class is a singleton, so it can be accessed from anywhere in the code.

There is a parameter regarding the environment type (stage and location), which is used to load different paths and other parameters based on the environment.

Classes:

Functions:

LangToolsParams

LangToolsParams()

LangTools project parameters.

Load the LangTools params.

Methods:

  • __repr__

    Return the string representation of the object.

  • __str__

    Return the string representation of the object.

  • load_config

    Load the lang_tools configuration.

  • set_env_type

    Set the environment type.

Source code in src/lang_tools/params/lang_tools_params.py
def __init__(self) -> None:
    """Load the LangTools params."""
    lg.info("Loading LangTools params")
    self.set_env_type()

__repr__

__repr__() -> str

Return the string representation of the object.

Source code in src/lang_tools/params/lang_tools_params.py
def __repr__(self) -> str:
    """Return the string representation of the object."""
    return str(self)

__str__

__str__() -> str

Return the string representation of the object.

Source code in src/lang_tools/params/lang_tools_params.py
def __str__(self) -> str:
    """Return the string representation of the object."""
    s = "LangToolsParams:"
    s += f"\n{self.paths}"
    s += f"\n{self.sample}"
    s += f"\n{self.webapp}"
    return s

load_config

load_config() -> None

Load the lang_tools configuration.

Source code in src/lang_tools/params/lang_tools_params.py
def load_config(self) -> None:
    """Load the lang_tools configuration."""
    self.paths = LangToolsPaths(env_type=self.env_type)
    self.sample = SampleParams()
    self.webapp = WebappParams(
        stage=self.env_type.stage,
        location=self.env_type.location,
    )

set_env_type

set_env_type(env_type: EnvType | None = None) -> None

Set the environment type.

Parameters:

  • env_type (EnvType | None, default: None ) –

    The environment type. If None, it will be set from the environment variables. Defaults to None.

Source code in src/lang_tools/params/lang_tools_params.py
def set_env_type(self, env_type: EnvType | None = None) -> None:
    """Set the environment type.

    Args:
        env_type (EnvType | None): The environment type.
            If None, it will be set from the environment variables.
            Defaults to None.
    """
    if env_type is not None:
        self.env_type = env_type
    else:
        self.env_type = EnvType.from_env_var()
    self.load_config()

get_lang_tools_params

get_lang_tools_params() -> LangToolsParams

Get the lang_tools params.

Source code in src/lang_tools/params/lang_tools_params.py
def get_lang_tools_params() -> LangToolsParams:
    """Get the lang_tools params."""
    return LangToolsParams()

get_lang_tools_paths

get_lang_tools_paths() -> LangToolsPaths

Get the lang_tools paths.

Source code in src/lang_tools/params/lang_tools_params.py
def get_lang_tools_paths() -> LangToolsPaths:
    """Get the lang_tools paths."""
    return get_lang_tools_params().paths

get_webapp_params

get_webapp_params() -> WebappParams

Get the webapp params.

Source code in src/lang_tools/params/lang_tools_params.py
def get_webapp_params() -> WebappParams:
    """Get the webapp params."""
    return get_lang_tools_params().webapp