AntonioJun commited on
Commit
83068db
·
verified ·
1 Parent(s): af2fea0

setup.sh: hf CLI migration + cached-login fallback + hard-fail downloads

Browse files
Files changed (1) hide show
  1. setup.sh +24 -3
setup.sh CHANGED
@@ -59,6 +59,7 @@ done
59
 
60
  log() { printf '\n\033[1;36m==> %s\033[0m\n' "$1"; }
61
  warn() { printf '\033[1;33m!! %s\033[0m\n' "$1" >&2; }
 
62
 
63
  # ---------------------------------------------------------------------------
64
  # 1. Hugging Face token (needed for facebook/sam3 and nyu-visionx/VSI-Bench, both
@@ -266,8 +267,19 @@ fi
266
  # checkpoints, the three VLMs -- all placed under their NATIVE hub repo basename
267
  # (matching MODEL_PATHS / encoder.config / VSI_ROOT lookups elsewhere in this repo).
268
  # ---------------------------------------------------------------------------
269
- HF_CLI="$VENV_ROOT/bin/huggingface-cli"
270
- [ -x "$HF_CLI" ] || HF_CLI="${PERCEPTION_VENV_ROOT}/bin/huggingface-cli"
 
 
 
 
 
 
 
 
 
 
 
271
 
272
  hf_download() {
273
  local repo_id="$1" repo_type="$2" dest="$3"
@@ -277,7 +289,16 @@ hf_download() {
277
  fi
278
  log "Downloading $repo_id ($repo_type) -> $dest"
279
  mkdir -p "$dest"
280
- "$HF_CLI" download "$repo_id" --repo-type "$repo_type" --local-dir "$dest" --token "$HF_TOKEN"
 
 
 
 
 
 
 
 
 
281
  }
282
 
283
  if [ "$SKIP_DATA" -eq 0 ]; then
 
59
 
60
  log() { printf '\n\033[1;36m==> %s\033[0m\n' "$1"; }
61
  warn() { printf '\033[1;33m!! %s\033[0m\n' "$1" >&2; }
62
+ die() { printf '\033[1;31mXX %s\033[0m\n' "$1" >&2; exit 1; }
63
 
64
  # ---------------------------------------------------------------------------
65
  # 1. Hugging Face token (needed for facebook/sam3 and nyu-visionx/VSI-Bench, both
 
267
  # checkpoints, the three VLMs -- all placed under their NATIVE hub repo basename
268
  # (matching MODEL_PATHS / encoder.config / VSI_ROOT lookups elsewhere in this repo).
269
  # ---------------------------------------------------------------------------
270
+ # Newer huggingface_hub versions removed `huggingface-cli` entirely in favor of
271
+ # `hf`; prefer `hf` wherever it exists and only fall back to the legacy name on
272
+ # old installs. A silent legacy-CLI failure here previously left VSI-Bench and
273
+ # every checkpoint undownloaded while the rest of setup continued.
274
+ HF_CLI=""
275
+ for candidate in "$VENV_ROOT/bin/hf" "${PERCEPTION_VENV_ROOT}/bin/hf" \
276
+ "$VENV_ROOT/bin/huggingface-cli" "${PERCEPTION_VENV_ROOT}/bin/huggingface-cli"; do
277
+ if [ -x "$candidate" ]; then HF_CLI="$candidate"; break; fi
278
+ done
279
+ if [ -z "$HF_CLI" ]; then
280
+ HF_CLI="$(command -v hf || command -v huggingface-cli || true)"
281
+ fi
282
+ [ -n "$HF_CLI" ] || { warn "no hf/huggingface-cli found; downloads will fail"; HF_CLI="hf"; }
283
 
284
  hf_download() {
285
  local repo_id="$1" repo_type="$2" dest="$3"
 
289
  fi
290
  log "Downloading $repo_id ($repo_type) -> $dest"
291
  mkdir -p "$dest"
292
+ # Pass --token only when HF_TOKEN is set -- otherwise defer to a cached
293
+ # `hf auth login`, instead of overriding it with an empty token (which broke
294
+ # gated downloads for logged-in users).
295
+ if [ -n "$HF_TOKEN" ]; then
296
+ "$HF_CLI" download "$repo_id" --repo-type "$repo_type" --local-dir "$dest" --token "$HF_TOKEN" \
297
+ || die "download failed: $repo_id"
298
+ else
299
+ "$HF_CLI" download "$repo_id" --repo-type "$repo_type" --local-dir "$dest" \
300
+ || die "download failed: $repo_id"
301
+ fi
302
  }
303
 
304
  if [ "$SKIP_DATA" -eq 0 ]; then