first (part 2: other directories)
Deploy Iddaai Backend / build-and-deploy (push) Failing after 18s

This commit is contained in:
2026-04-16 15:11:25 +03:00
parent 7814e0bc6b
commit 2f0b85a0c7
203 changed files with 59989 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
"""
League Reliability Loader
=========================
Loads pre-computed per-league odds reliability scores from
data/league_reliability.json. Called once at orchestrator startup.
The reliability score (0.0 1.0) represents how well-calibrated
a league's betting odds are based on historical Brier Score analysis.
Usage:
from utils.league_reliability import load_league_reliability
lookup = load_league_reliability()
rel = lookup.get(league_id, 0.35)
"""
from __future__ import annotations
import json
import os
from typing import Dict
_DATA_FILE = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"..",
"data",
"league_reliability.json",
)
def load_league_reliability() -> Dict[str, float]:
"""
Returns a dict mapping league_id → odds_reliability (0.0-1.0).
Falls back gracefully to an empty dict if the file is missing.
"""
if not os.path.isfile(_DATA_FILE):
print(
f"⚠️ league_reliability.json not found at {_DATA_FILE}. "
"All leagues will use default reliability (0.35)."
)
return {}
try:
with open(_DATA_FILE, "r", encoding="utf-8") as f:
data = json.load(f)
lookup: Dict[str, float] = data.get("lookup", {})
total = len(lookup)
print(f"✅ Loaded odds reliability for {total} leagues")
return lookup
except (json.JSONDecodeError, KeyError, TypeError) as exc:
print(f"⚠️ Failed to parse league_reliability.json: {exc}")
return {}