Configuration
config ¶
Application configuration and runtime constants for Leeroy.
Purpose
Defines environment helpers, filesystem paths, model settings, database paths, logging configuration, Streamlit UI labels, runtime defaults, mode names, compiled text patterns, and help text used throughout the Leeroy application. The module keeps configuration import-safe by returning defaults when optional environment variables are missing or malformed.
throw_if ¶
Raise a ValueError when a required value is empty.
Purpose
Provides a consistent guard for required arguments and configuration values used
by Leeroy helpers. The function treats falsy values as invalid and raises a
ValueError containing the caller-supplied argument or setting name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the argument or configuration value being validated. |
required |
value
|
object
|
Value to validate. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when |
Source code in config.py
get_bool ¶
Read a Boolean environment variable.
Purpose
Converts environment-variable text into a deterministic Boolean value for optional
runtime settings. Missing variables return the caller-provided default. Values of
1, true, yes, y, and on are treated as True; all other
defined values are treated as False.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
bool
|
Default value used when the environment variable is not defined. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Parsed Boolean value, or the original default value when parsing fails. |
Source code in config.py
get_int ¶
Read an integer environment variable.
Purpose
Parses an optional environment variable as an integer while preserving a safe default when the variable is missing, empty, or invalid. This keeps module import safe even when deployment configuration is incomplete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
int
|
Default integer value used when parsing is not possible. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Parsed integer value or the supplied default value. |
Source code in config.py
get_float ¶
Read a floating-point environment variable.
Purpose
Parses an optional environment variable as a float while preserving a safe default when the variable is missing, empty, or invalid. This helper supports numeric configuration without making module import dependent on perfect environment state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
float
|
Default floating-point value used when parsing is not possible. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Parsed floating-point value or the supplied default value. |
Source code in config.py
get_path ¶
Read a path environment variable.
Purpose
Resolves optional filesystem configuration from the environment. Missing variables return the resolved default path, and invalid values fall back to the resolved default path rather than interrupting module import.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
Path
|
Default path used when the environment variable is not defined. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Resolved path value or the resolved default path. |
Source code in config.py
get_text ¶
Read a text environment variable.
Purpose
Returns an environment variable as text while preserving the supplied default when the variable is missing or empty. This keeps optional configuration centralized and stable for callers that import the module early in application startup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
str
|
Default text value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Environment value or supplied default. |