(self)
| 623 | logger.warning("Benchmark cache save failed: %s", exc) |
| 624 | |
| 625 | def _load_cache(self) -> None: |
| 626 | if not _CACHE_PATH.exists(): |
| 627 | return |
| 628 | try: |
| 629 | raw = json.loads(_CACHE_PATH.read_text(encoding="utf-8")) |
| 630 | self._last_refresh = float(raw.get("last_refresh", 0)) |
| 631 | for source_name, entries_raw in raw.get("sources", {}).items(): |
| 632 | entries: dict[str, ModelBenchmarkEntry] = {} |
| 633 | for model_id, values in entries_raw.items(): |
| 634 | entries[model_id] = ModelBenchmarkEntry( |
| 635 | overall=float(values.get("overall", 0.5)), |
| 636 | categories=dict(values.get("categories", {})), |
| 637 | raw=dict(values.get("raw", {})), |
| 638 | fetched_at=float(values.get("fetched_at", 0)), |
| 639 | ) |
| 640 | self._sources[source_name] = entries |
| 641 | except Exception as exc: |
| 642 | logger.warning("Benchmark cache load failed: %s", exc) |
| 643 | |
| 644 | |
| 645 | _ACTIVE_CACHE: BenchmarkCache | None = None |
no test coverage detected