A few targeted tweaks to address HF rate limits#2009
Merged
Conversation
rltakashige
reviewed
Apr 30, 2026
| api_url = f"{get_hf_endpoint()}/api/models/{model_id}/tree/{revision}" | ||
| url = f"{api_url}/{path}" if path else api_url | ||
| # ?recursive=true returns the whole subtree in one request | ||
| if recursive: |
rltakashige
approved these changes
Apr 30, 2026
Collaborator
rltakashige
left a comment
There was a problem hiding this comment.
Sloppy slop slop but I'll approve this to unblock us as I don't think it breaks any existing functionality.
| on_connection_lost: Callable[[], None] = lambda: None, | ||
| ) -> list[FileListEntry]: | ||
| n_attempts = 3 | ||
| n_attempts = 5 |
| return None | ||
|
|
||
|
|
||
| # reset window is 5 min |
| @@ -0,0 +1,355 @@ | |||
| """Tests for HuggingFace 429 rate-limit handling in download_utils.""" | |||
Collaborator
There was a problem hiding this comment.
oh my god a billion more lines of tests :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
file_metaand_download_filehad no 429 handling at all (becameAssertionError).Changes
All in
src/exo/download/download_utils.py+ tests.t=from HF'sRateLimitheader on 429; sleepmin(t, 300s) + jitter._fetch_file_list,file_meta,_download_file).n_attempts: 3 → 5.?recursive=trueinstead of N+1 subdir walks.Why It Works
t=<seconds>is HF's "wait this long and you'll be unblocked" — sleeping that long lets the window reset. Disk-cache-as-primary plus recursive listing cuts cold-start Hub-API traffic by ~10×.Test Plan
Manual Testing
MacBook Pro M1 Max. Tripped the real HF 429. Pre-fix: failed in 3.4s. Post-fix: slept (HF returned
t=158) and recovered.Automated Testing
test_rate_limit_handling.py(19 tests) — header parsing, retry-loop behaviour, plus HTTP-level coverage that mocks aiohttp to return a 429 and asserts each call site raisesHuggingFaceRateLimitError(retry_after=52.0).TestFileListCacheTTLintest_offline_mode.py— fresh cache hits, stale cache refetches.