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

Method refresh

uncommon_route/benchmark.py:279–305  ·  view source on GitHub ↗

Fetch from all providers. Returns number of models updated.

(self, force: bool = False)

Source from the content-addressed store, hash-verified

277 self._source_weights[provider.source_name] = weight
278
279 async def refresh(self, force: bool = False) -> int:
280 """Fetch from all providers. Returns number of models updated."""
281 total = 0
282 for provider in self._providers:
283 if not force:
284 source_data = self._sources.get(provider.source_name, {})
285 if source_data:
286 newest = max((e.fetched_at for e in source_data.values()), default=0)
287 if time.time() - newest < provider.refresh_interval_s:
288 continue
289 try:
290 entries = await provider.fetch()
291 if entries:
292 self._sources[provider.source_name] = entries
293 total += len(entries)
294 logger.info(
295 "Benchmark refresh: %d models from %s",
296 len(entries),
297 provider.source_name,
298 )
299 except Exception as exc:
300 logger.warning("Benchmark refresh failed for %s: %s", provider.source_name, exc)
301 if total > 0:
302 self._last_refresh = time.time()
303 self._save_cache()
304 self._build_index()
305 return total
306
307 def needs_refresh(self, *, now: float | None = None) -> bool:
308 """Return whether any configured source is missing or past its TTL."""

Callers 4

refresh_if_staleMethod · 0.95
_runnerMethod · 0.95
_on_startupFunction · 0.80
_benchmark_refresh_loopFunction · 0.80

Calls 5

_save_cacheMethod · 0.95
_build_indexMethod · 0.95
infoMethod · 0.80
getMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected