ui-copilot / backend /utils /config_loader.py
ksri77's picture
chore: deploy from CI
8c816e3 verified
Raw
History Blame Contribute Delete
662 Bytes
from __future__ import annotations
import json
from functools import lru_cache
from pathlib import Path
_CONFIG_PATH = Path(__file__).resolve().parents[2] / "config" / "scoring.json"
@lru_cache(maxsize=1)
def load_scoring_config() -> dict:
try:
with _CONFIG_PATH.open() as f:
return json.load(f)
except FileNotFoundError:
raise FileNotFoundError(
f"Scoring config not found: {_CONFIG_PATH}. "
"Ensure config/scoring.json exists in the project root."
) from None
except json.JSONDecodeError as exc:
raise ValueError(f"Malformed scoring config at {_CONFIG_PATH}: {exc}") from exc