aiq.utils.io.yaml_tools#

Attributes#

Functions#

_interpolate_variables(→ str | int | float | bool | None)

Interpolate variables in a string with the format ${VAR:-default_value}.

yaml_load(→ dict)

Load a YAML file and interpolate variables in the format

yaml_loads(→ dict)

Load a YAML string and interpolate variables in the format

yaml_dump(→ None)

Dump a configuration dictionary to a YAML file.

yaml_dumps(→ str)

Dump a configuration dictionary to a YAML string.

Module Contents#

logger#
_interpolate_variables(
value: str | int | float | bool | None,
) str | int | float | bool | None#

Interpolate variables in a string with the format ${VAR:-default_value}. If the variable is not set, the default value will be used. If no default value is provided, an empty string will be used.

Args:

value (str | int | float | bool | None): The value to interpolate variables in.

Returns:

str | int | float | bool | None: The value with variables interpolated.

yaml_load(config_path: aiq.utils.type_utils.StrPath) dict#

Load a YAML file and interpolate variables in the format ${VAR:-default_value}.

Args:

config_path (StrPath): The path to the YAML file to load.

Returns:

dict: The processed configuration dictionary.

yaml_loads(config: str) dict#

Load a YAML string and interpolate variables in the format ${VAR:-default_value}.

Args:

config (str): The YAML string to load.

Returns:

dict: The processed configuration dictionary.

yaml_dump(config: dict, fp: TextIO) None#

Dump a configuration dictionary to a YAML file.

Args:

config (dict): The configuration dictionary to dump. fp (typing.TextIO): The file pointer to write the YAML to.

yaml_dumps(config: dict) str#

Dump a configuration dictionary to a YAML string.

Args:

config (dict): The configuration dictionary to dump.

Returns:

str: The YAML string.