Skip to content

Udhul/dynamic-config-manager

Repository files navigation

Dynamic Config Manager

A singleton manager for handling multiple, strongly-typed configuration sets using Pydantic and Pydantic-Settings.

Features

  • Singleton Access via ConfigManager
  • Type Safety & Validation using Pydantic models
  • Automatic Persistence to JSON/YAML/TOML
  • Metadata extraction to power UIs

Installation

pip install dynamic-config-manager
# optional file format extras
pip install dynamic-config-manager[yaml,toml]

Quick CLI Example

dcm-cli show config.json
# update a value
dcm-cli set config.json ui.theme dark

Quick Start

Define your configuration using Pydantic models, register it with the manager and access values safely:

from dynamic_config_manager import ConfigManager, DynamicBaseSettings, ConfigField

class UIConfig(DynamicBaseSettings):
    theme: str = ConfigField("light", options=["light", "dark"])

cfg = ConfigManager.register("ui", UIConfig, auto_save=True)
cfg.active.theme = "dark"  # validated and persisted

Documentation

User and API documentation is available in the docs/ directory.

Watching for Changes

from dynamic_config_manager import watch_and_reload

thread, stop = watch_and_reload(["ui"], debounce=100)
# ... make changes to ui.json from another process ...
stop.set()  # stop watching

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages