mirror of
https://github.com/zylon-ai/private-gpt.git
synced 2025-12-22 13:55:41 +01:00
fix: Remove global state (#1216)
* Remove all global settings state * chore: remove autogenerated class * chore: cleanup * chore: merge conflicts
This commit is contained in:
parent
f394ca61bb
commit
022bd718e3
24 changed files with 286 additions and 190 deletions
|
|
@ -2,6 +2,7 @@ import functools
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
|
@ -28,7 +29,11 @@ active_profiles: list[str] = unique_list(
|
|||
)
|
||||
|
||||
|
||||
def load_profile(profile: str) -> dict[str, Any]:
|
||||
def merge_settings(settings: Iterable[dict[str, Any]]) -> dict[str, Any]:
|
||||
return functools.reduce(deep_update, settings, {})
|
||||
|
||||
|
||||
def load_settings_from_profile(profile: str) -> dict[str, Any]:
|
||||
if profile == "default":
|
||||
profile_file_name = "settings.yaml"
|
||||
else:
|
||||
|
|
@ -42,9 +47,11 @@ def load_profile(profile: str) -> dict[str, Any]:
|
|||
return config
|
||||
|
||||
|
||||
def load_active_profiles() -> dict[str, Any]:
|
||||
def load_active_settings() -> dict[str, Any]:
|
||||
"""Load active profiles and merge them."""
|
||||
logger.info("Starting application with profiles=%s", active_profiles)
|
||||
loaded_profiles = [load_profile(profile) for profile in active_profiles]
|
||||
merged: dict[str, Any] = functools.reduce(deep_update, loaded_profiles, {})
|
||||
loaded_profiles = [
|
||||
load_settings_from_profile(profile) for profile in active_profiles
|
||||
]
|
||||
merged: dict[str, Any] = merge_settings(loaded_profiles)
|
||||
return merged
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue