Config
Load fusion.<env>.json and core/settings.py with fusion_framework.config
Overview
fusion_framework.config is the Python façade over shared settings in fusion-core.
Runtime values live in fusion.<env>.json. Optional Python overlay lives in core/settings.py. The active environment comes from FUSION_ENV (default: dev).
For discovery rules, envelope vs flat JSON, env placeholders, and the full annotated fusion.dev.json / stage / prod schema, see the shared guide:
from fusion_framework.config import load_settings_module, get_settings
load_settings_module("settings")
s = get_settings()
print(s.host, s.port, s.debug)What the module exports
| Symbol | Role |
|---|---|
settings | Global singleton settings object |
Settings | Class (usually you use the singleton) |
get_settings() | Ensure JSON is loaded, return the singleton |
load_settings_module(...) | Load JSON + merge UPPERCASE attrs from a Python module |
configure(**kwargs) | Set values in code without editing JSON |
Also available as:
from fusion_framework import settingsTypical startup in main.py
from fusion_framework.app import FusionApp
from fusion_framework.config import get_settings, load_settings_module
MIDDLEWARE: list = []
def main() -> None:
load_settings_module("settings") # 1) JSON + core/settings.py
app = FusionApp(get_settings()) # 2) host / port / debug
for mw in MIDDLEWARE:
app.use(mw)
app.listen() # 3) start server
if __name__ == "__main__":
main()load_settings_module
load_settings_module("settings")
# or
load_settings_module("core.settings")What it does:
- Discovers and loads
fusion.<env>.json(cwd, parents,__main__dir) - Imports the Python module (
settings→ also triescore.settings) - Merges only UPPERCASE names from that module onto the settings object
# core/settings.py
from fusion_framework import settings
SECRET_KEY = settings.get("secret_key")
DEBUG = settings.get("debug", default=False)get_settings and the settings object
s = get_settings()
s.host # str, default "127.0.0.1"
s.port # int, default 3000 (scaffold uses 8080 in fusion.dev.json)
s.debug # bool
s.env # "dev" | "prod" | "stage" | …| API | Purpose |
|---|---|
settings.get("key", default=...) | Read a config key (supports dotted paths) |
settings["key"] | Same, raises KeyError if missing |
settings.host / .port / .debug / .env | Common fields |
settings.merge({...}) / configure(**kwargs) | Overlay |
settings.load_json(...) / ensure_loaded() | Explicit / lazy load |
Switch environment
FUSION_ENV=prod python main.py
fusion command run:prodMental model
fusion.dev.json → config block → settings singleton
core/settings.py → UPPERCASE overlay (optional)
get_settings() → FusionApp.listen(host, port)JSON is the source of truth. See Settings for keys (host, port, fingerprint, swagger, …) and CLI-generated file contents.