Skip to content

latent.config

TOML configuration loading for Latent framework.

This module provides centralized configuration management that can be loaded from a TOML file as an alternative to environment variables. The priority order is: 1. Environment variables (highest priority) 2. TOML configuration file (config/latent.toml) 3. Default values (lowest priority)

Example TOML configuration file (config/latent.toml):

[workspace]
root = "/path/to/workspace"
flows_dir = "flows"
data_dir = "data"
logs_dir = "logs"
mlruns_dir = "mlruns"

[mlflow]
enabled = true
litellm_autolog = true

[logging]
level = "INFO"

Classes

AgentsConfig

AgentsConfig(scan_paths: list[str] = (lambda: ['agents/*/agent.py'])())

Agent discovery configuration.

LatentConfig

LatentConfig(environment: str = 'production', workspace: WorkspaceConfig = WorkspaceConfig(), mlflow: MLflowConfig = MLflowConfig(), logging: LoggingConfig = LoggingConfig(), agents: AgentsConfig = AgentsConfig(), _config_file_path: Path | None = None)

Complete Latent framework configuration.

LoggingConfig

LoggingConfig(level: str = 'INFO', format: str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')

Logging configuration.

MLflowConfig

MLflowConfig(enabled: bool = True, tracking_uri: str | None = None, experiment_name: str | None = None, litellm_autolog: bool = True, langchain_autolog: bool = True, autolog: bool | None = None)

MLflow configuration defaults.

WorkspaceConfig

WorkspaceConfig(root: str | None = None, flows_dir: str | None = None, data_dir: str | None = None, logs_dir: str | None = None, mlruns_dir: str | None = None, mlartifacts_dir: str | None = None, cache_dir: str | None = None, stable_dir: str | None = None, fixtures_dir: str | None = None)

Workspace directory configuration.

Functions

generate_sample_config

generate_sample_config(output_path: Path | str | None = None) -> str

Generate a sample configuration file.

Args: output_path: Optional path to write the sample config to

Returns: Sample configuration content as string

get_config_bool

get_config_bool(section: str, key: str, env_var: str | None = None, default: bool = False) -> bool

Get a boolean configuration value with environment variable override.

Args: section: Configuration section key: Configuration key within the section env_var: Environment variable name to check first default: Default value if not found anywhere

Returns: Boolean configuration value

get_config_value

get_config_value(section: str, key: str, env_var: str | None = None, default: str | None = None) -> str | None

Get a configuration value with environment variable override.

Priority order: 1. Environment variable (if env_var is specified and set) 2. TOML config file value 3. Default value

Args: section: Configuration section (e.g., "workspace", "mlflow") key: Configuration key within the section env_var: Environment variable name to check first default: Default value if not found anywhere

Returns: Configuration value or default

Example: >>> # Gets LATENT_WORKSPACE_ROOT env var, or workspace.root from TOML, or None >>> root = get_config_value("workspace", "root", "LATENT_WORKSPACE_ROOT")

get_environment

get_environment() -> str

Get current environment setting.

Environment values: - "dev" or "development": Development mode (disables caching) - "production": Production mode (default, enables caching)

Priority order: 1. LATENT_ENVIRONMENT environment variable 2. environment field in TOML config 3. "production" (default)

Returns: Environment string (e.g., "dev", "development", "production")

Example: >>> env = get_environment() >>> if env in ("dev", "development"): ... print("Running in development mode")

is_development_mode

is_development_mode() -> bool

Check if running in development mode.

Development mode is active when environment is set to "dev" or "development". This automatically disables task caching for faster iteration.

Returns: True if in development mode, False otherwise

Example: >>> if is_development_mode(): ... print("Caching disabled for development")

load_config

load_config(config_path: Path | str | None = None) -> LatentConfig

Load the Latent configuration from TOML file.

This function is cached - subsequent calls return the same config. Use reload_config() to force a refresh.

Args: config_path: Explicit path to config file (optional). If not provided, searches in standard locations.

Returns: LatentConfig object with loaded (or default) configuration

reload_config

reload_config(config_path: Path | str | None = None) -> LatentConfig

Force reload the configuration from disk.

This clears the cache and reloads the configuration file.

Args: config_path: Explicit path to config file (optional)

Returns: Freshly loaded LatentConfig object

Attributes

CONFIG_FILE_PATHS

SAMPLE_CONFIG_TEMPLATE