MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _load

Method _load

uncommon_route/spend_control.py:276–289  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

274 })
275
276 def _load(self) -> None:
277 data = self._storage.load()
278 if not data:
279 return
280 for key in ("per_request", "hourly", "daily", "session"):
281 val = data.get("limits", {}).get(key)
282 if val is not None:
283 setattr(self._limits, key, float(val))
284 for r in data.get("history", []):
285 self._history.append(SpendRecord(
286 timestamp=r["timestamp"], amount=r["amount"],
287 model=r.get("model"), action=r.get("action"),
288 ))
289 self._cleanup()
290
291
292def format_duration(seconds: int) -> str:

Callers 1

__init__Method · 0.95

Calls 5

_cleanupMethod · 0.95
SpendRecordClass · 0.85
loadMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected