Skip to content

Commit 1d43abc

Browse files
authored
verify-superset: retry transient 429/5xx with backoff before failing closed (#42)
1 parent 5a6d2dc commit 1d43abc

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

tools/verify-superset.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,19 @@ repo="${2:?usage: verify-superset.sh <folder> <hf_repo_id> [repo_type]}"
1313
rtype="${3:-dataset}" # dataset | space | model — selects the /api/<type>s tree endpoint
1414
tok="${HF_TOKEN:-$(hf auth token 2>/dev/null)}"
1515

16-
code=$(curl -s -o /tmp/tree.json -w '%{http_code}' \
17-
-H "Authorization: Bearer $tok" \
18-
"https://huggingface.co/api/${rtype}s/$repo/tree/main?recursive=true")
16+
# Fetch the Hub tree, retrying transient failures (429 rate-limit, 5xx) with short
17+
# backoff so a momentary rate-limit doesn't hard-block a legitimate sync. 200/404 are
18+
# terminal; a still-transient code after the last try falls through to "fail closed".
19+
code=000
20+
for attempt in 1 2 3; do
21+
code=$(curl -s -o /tmp/tree.json -w '%{http_code}' \
22+
-H "Authorization: Bearer $tok" \
23+
"https://huggingface.co/api/${rtype}s/$repo/tree/main?recursive=true")
24+
case "$code" in
25+
429|5??) echo "… Hub API returned HTTP $code for $repo; retry $attempt/3 after ${attempt}s…" >&2; sleep "$attempt" ;;
26+
*) break ;;
27+
esac
28+
done
1929

2030
case "$code" in
2131
404) echo "✅ OK — $repo doesn't exist yet (brand-new repo); nothing on the Hub to preserve."; exit 0 ;;

0 commit comments

Comments
 (0)