File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,9 +13,19 @@ repo="${2:?usage: verify-superset.sh <folder> <hf_repo_id> [repo_type]}"
1313rtype=" ${3:- dataset} " # dataset | space | model — selects the /api/<type>s tree endpoint
1414tok=" ${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
2030case " $code " in
2131 404) echo " ✅ OK — $repo doesn't exist yet (brand-new repo); nothing on the Hub to preserve." ; exit 0 ;;
You can’t perform that action at this time.
0 commit comments