abx_spec_config.base_configset
Module Contents
Classes
A source class that loads variables from a TOML file |
|
This is the base class for an ArchiveBox ConfigSet. It handles loading values from schema defaults, ArchiveBox.conf TOML config, and environment variables. |
Functions
returns True if a lambda func takes args/kwargs of any kind, otherwise false if it’s pure/argless |
|
Convert an INI file to a TOML file, saving the original to .ORIGINALNAME.bak |
Data
API
- abx_spec_config.base_configset.AUTOFIXES_SUBHEADER[source]
‘# The following config was added automatically to fix problems detected at startup:’
- class abx_spec_config.base_configset.FlatTomlConfigSettingsSource(settings_cls: type[pydantic_settings.BaseSettings], toml_file: pathlib.Path | None = None)[source]
Bases:
pydantic_settings.sources.TomlConfigSettingsSource
A source class that loads variables from a TOML file
Initialization
- class abx_spec_config.base_configset.BaseConfigSet[source]
Bases:
pydantic_settings.BaseSettings
This is the base class for an ArchiveBox ConfigSet. It handles loading values from schema defaults, ArchiveBox.conf TOML config, and environment variables.
class WgetConfig(ArchiveBoxBaseConfig): WGET_BINARY: str = Field(default=’wget’, alias=’WGET_BINARY_PATH’)
c = WgetConfig() print(c.WGET_BINARY) # outputs: wget
you can mutate process environment variable and reload config using .init()
os.environ[‘WGET_BINARY_PATH’] = ‘wget2’ c.init()
print(c.WGET_BINARY) # outputs: wget2
- classmethod settings_customise_sources(settings_cls: Type[pydantic_settings.BaseSettings], init_settings: pydantic_settings.PydanticBaseSettingsSource, env_settings: pydantic_settings.PydanticBaseSettingsSource, dotenv_settings: pydantic_settings.PydanticBaseSettingsSource, file_secret_settings: pydantic_settings.PydanticBaseSettingsSource) Tuple[pydantic_settings.PydanticBaseSettingsSource, ...] [source]
Defines the config precedence order: Schema defaults -> ArchiveBox.conf (TOML) -> Environment variables
- get_default_value(key: abx_spec_config.base_configset.ConfigKeyStr)[source]
Get the default value for a given config key
- update_in_place(warn=False, persist=False, hint='', **kwargs)[source]
Update the config with new values. Use this sparingly! We should almost never be updating config at runtime. Sets them in the environment so they propagate to spawned subprocesses / across future re-init()s and reload from environment
Example acceptable use case: user config says SEARCH_BACKEND_ENGINE=sonic but sonic_client pip library is not installed so we cannot use it. SEARCH_BACKEND_CONFIG.update_in_place(SEARCH_BACKEND_ENGINE=’ripgrep’) can be used to reset it back to ripgrep so we can continue.
- property aliases: Dict[abx_spec_config.base_configset.ConfigKeyStr, abx_spec_config.base_configset.ConfigKeyStr][source]
- property toml_section_header[source]
Convert the class name to a TOML section header e.g. ShellConfig -> SHELL_CONFIG
- from_defaults() Dict[abx_spec_config.base_configset.ConfigKeyStr, Any] [source]
Get the dictionary of {key: value} config loaded from the default values
- from_collection() Dict[abx_spec_config.base_configset.ConfigKeyStr, Any] [source]
Get the dictionary of {key: value} config loaded from the collection ArchiveBox.conf
- from_environment() Dict[abx_spec_config.base_configset.ConfigKeyStr, Any] [source]
Get the dictionary of {key: value} config loaded from the environment variables
- from_computed() Dict[abx_spec_config.base_configset.ConfigKeyStr, Any] [source]
Get the dictionary of {key: value} config loaded from the computed fields