Spaces:
Running on CPU Upgrade
Back off on Semantic Scholar rate limits and cache aggressively
The Space was stuck in RUNTIME_ERROR: example caching at startup hit unauthenticated Semantic Scholar 429s, which surfaced as KeyError 'recommendedPapers' and killed launch.
- Retry S2 calls with exponential backoff + jitter via stamina (429, 5xx, network errors; 6 attempts, 120 s budget)
- raise_for_status + 30 s request timeout; distinct user-facing message for rate limiting vs not-indexed
- Cache recommendations for 7 days (maxsize 10k) instead of 6 h / 500
- cache_examples='lazy' so an S2 outage can't stop startup
- Optional S2_API_KEY secret sent as x-api-key
๐ค Generated with Claude Code
Update: bumped all deps (gradio 6.1โ6.30, huggingface-hub 1.2โ2.3, cachetools 6โ7, starlette 0.50โ1.9, requests 2.32โ2.34 โฆ) and dropped unused datasets, beautifulsoup4, lxml (removes pandas/pyarrow from the image). Also fixed lazy caching: gradio 6 wants cache_examples=True, cache_mode="lazy", not cache_examples="lazy".
Smoke-tested locally on both the old and new pins (CommitScheduler stubbed): app launches, /return_recommendations endpoint name unchanged, returns recommendations for 2309.12307.
Ready for merge
Merging: S2 backoff + caching + dep bump