avid.common.config_manager

Central TOML-based configuration manager for AVID.

This module provides functions to manage configuration at two levels:

  • User requested_scope: stored in the OS-specific user config/data dirs (via platformdirs).

  • Venv requested_scope: stored under the current virtual environment root (<venv>/etc/avid for configs, <venv>/var/avid for tools).

When loading settings, venv values always override user values (merged view). When writing, callers can explicitly choose user or venv. If no requested_scope is given, the default is venv if inside a virtual environment, else user.

Tool configurations are stored in dedicated TOML files, one per tool, located under the respective tools root (.../tools/tool-configs/<tool-id>/avid_tool_config.toml).

Functions

collect_keys_from_config_dict(config_dict)

Returns a set with all toml keys found in a dict

ensure_dir(p)

Ensure that the given directory exists.

get_setting(key[, scope])

Retrieve a setting value.

get_setting_from_dict(key, config_dict)

Retrieve a setting value.

get_user_config_dir()

Return the base user configuration directory for AVID. Example (Linux): ~/.config/avid.

get_user_config_file_path()

Return the path to the user-level config TOML file.

get_user_data_dir()

Return the base user data directory for AVID. This is e.g. the root where the tools path is located by default Example (Linux): ~/.local/share/avid.

get_user_tool_config_dir(tool_id)

Return path to a tool's config dir.

get_user_tool_config_file_path(tool_id)

Return path to a tool's TOML config file.

get_user_tools_default_root_dir()

Return the default root directory for installed tools. Example (Linux): ~/.local/share/avid/tools.

get_user_tools_root_dir()

Return the root directory for installed tools.

get_valid_scope([requested_scope])

get_venv_config_dir()

Return the configuration directory for the current venv. Layout: <venv>/etc/avid :returns: Optional[Path]: Path to venv config dir, or None if not in venv.

get_venv_config_file_path()

Return the path to the venv-level config TOML file, if in venv.

get_venv_data_dir()

Return the data directory for the current venv. Layout: <venv>/bin/avid :returns: Optional[Path]: Path to venv data dir, or None if not in venv.

get_venv_root_dir()

Return the current virtual environment root, if any.

get_venv_tool_config_dir(tool_id)

Return path to a tool's TOML config dir for the current venv.

get_venv_tool_config_file_path(tool_id)

Return path to a tool's TOML config file for the current venv.

get_venv_tools_default_root_dir()

Return the default root directory for installed tools for the current venv. Example (Linux): ~/.local/share/avid/tools.

get_venv_tools_root_dir()

Return the root directory for installed tools for the current venv.

in_venv()

Return whether execution is inside a virtual environment.

load_merged_config()

Load merged configuration: defaults < user < venv.

load_user_config()

Load the user-level configuration file.

load_user_tool_config(tool_id)

Load the user-level tool configuration file, if available.

load_venv_config()

Load the venv-level configuration file, if available.

load_venv_tool_config(tool_id)

Load the venv-level tool configuration file, if available.

save_user_config(cfg)

Write user-level config.

save_user_tool_config(tool_id, cfg)

Write user-level config.

save_venv_config(cfg)

Write venv-level config (error if not in venv).

save_venv_tool_config(tool_id, cfg)

Write venv-level config (error if not in venv).

set_setting(key, value[, scope])

Set a configuration value.

set_setting_in_dict(key, config_dict, value)

Set a configuration value.

unset_setting(key[, scope])

Remove a setting.

unset_setting_in_dict(key, config_dict)

Remove a setting.

Classes

SETTING_NAMES()

TOOL_SETTING_NAMES()