Config Manager
- class axisfuzzy.config.manager.ConfigManager[source]
Bases:
objectSingleton manager for application configuration.
The manager holds a single
Configinstance, provides load/save/reset operations, and validates updates against field metadata.Notes
The class implements a thread-safe singleton pattern: multiple imports will share the same manager instance.
- add_config_observer(observer)[source]
Register an observer for config changes.
- Parameters:
observer (Any) – Observer object. Observer semantics are reserved for future use.
- static create_config_template(file_path)[source]
Create a JSON configuration template file populated with defaults.
- Parameters:
file_path (str or pathlib.Path) – Destination path for the template JSON. Parent directories will be created.
Notes
The generated file contains some top-level comment/metadata fields alongside the actual default configuration for easy editing.
- get_config()[source]
Return the active Config instance.
- Returns:
The current configuration dataclass.
- Return type:
Config
- get_config_history()[source]
Return a shallow copy of the configuration change history.
- Returns:
The stored configuration history entries (currently unused).
- Return type:
list
- get_config_source()[source]
Return the path of the source file if the configuration was loaded from a file.
- Returns:
File path string or None when configuration was not loaded from a file.
- Return type:
str or None
- get_config_summary()[source]
Produce a categorized summary of current configuration.
- Returns:
Mapping of category -> {field_name: value}, with an additional ‘meta’ key that contains ‘config_source’ and ‘is_modified’.
- Return type:
dict
- is_modified()[source]
Check whether configuration was modified since last save/load.
- Returns:
True if modified, False otherwise.
- Return type:
bool
- load_config_file(file_path)[source]
Load configuration from a JSON file and apply it.
- Parameters:
file_path (str or pathlib.Path) – Path to the JSON configuration file.
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If the file content is not a dict or a validation error occurs.
RuntimeError – For unexpected IO/parse errors.
- remove_observer(observer)[source]
Remove a previously registered observer.
- Parameters:
observer (Any) – Observer to remove. No-op if observer not registered.
- reset_config()[source]
Reset configuration to defaults.
This replaces the internal Config instance with a new default instance and clears source/modified flags.
- save_config_file(file_path)[source]
Save the current configuration to a JSON file.
- Parameters:
file_path (str or pathlib.Path) – Destination path for the JSON file. Parent directories are created automatically.
- Raises:
RuntimeError – If the file cannot be written.
- set_config(**kwargs)[source]
Set one or more configuration fields.
- Parameters:
**kwargs – Mapping of configuration field names to desired values.
- Raises:
ValueError – If an unknown key is provided or a value fails validation.
Examples
>>> mgr = ConfigManager() >>> mgr.set_config(DEFAULT_PRECISION=6)