aiq.cli.cli_utils.config_override#

Attributes#

Classes#

Functions#

load_and_override_config(→ dict[str, Any])

Load config file and apply any overrides

add_override_option(command)

Decorator to add override option to a command

Module Contents#

logger#
class LayeredConfig(base_config: dict[str, Any])#
base_config#
overrides: dict[str, Any]#
_effective_config: dict[str, Any] | None = None#
validate_path(path: str) None#

Validate if a path exists in base config

set_override(path: str, value: str) None#

Set an override value with type conversion based on original config value.

Args:

path: Configuration path in dot notation (e.g., “llms.nim_llm.temperature”) value: String value from CLI to override with

Raises:

click.BadParameter: If path doesn’t exist or type conversion fails Exception: For other unexpected errors

get_value(path: str) Any#

Get value with better error messages

_update_config_value(
config: dict[str, Any],
path: str,
value: Any,
) None#

Update a single value in the config dictionary at the specified path.

Args:

config: The configuration dictionary to update path: String representing the path to the value using dot notation (e.g. “llms.nim_llm.temperature”) value: The new value to set at the specified path

Example:

If config is {“llms”: {“nim_llm”: {“temperature”: 0.5}}} and path is “llms.nim_llm.temperature” with value 0.7, this will update config to {“llms”: {“nim_llm”: {“temperature”: 0.7}}}

get_effective_config() dict[str, Any]#

Get the configuration with all overrides applied.

Creates a new configuration dictionary by applying all stored overrides to a deep copy of the base configuration. Caches the result to avoid recomputing unless overrides change.

Returns:

Dict containing the full configuration with all overrides applied

Note:

The configuration is cached in self._effective_config and only recomputed when new overrides are added via set_override()

load_and_override_config(
config_file: pathlib.Path,
overrides: tuple[tuple[str, str], Ellipsis],
) dict[str, Any]#

Load config file and apply any overrides

add_override_option(command)#

Decorator to add override option to a command