SlowGuess's picture
Upload Abforge training code snapshot
1ce6f9b verified
Raw
History Blame Contribute Delete
1.47 kB
#!/bin/bash
# Verify the project-local SlowGuess HF token WITHOUT printing it and WITHOUT
# touching the global (chengyewang) login cached at ~/.cache/huggingface/token.
#
# It sources secrets/hf_slowguess.env (which sets HF_TOKEN) into THIS process
# only, then asks the Hub who that token belongs to and whether it can write.
set -euo pipefail
WORK=/gpfs/radev/scratch/cohan/yz979/xucai/Abforge_Training
ENVF=$WORK/secrets/hf_slowguess.env
[[ -f "$ENVF" ]] || { echo "FATAL: $ENVF not found"; exit 1; }
# shellcheck disable=SC1090
set -a; source "$ENVF"; set +a
[[ -n "${HF_TOKEN:-}" ]] || { echo "FATAL: HF_TOKEN empty in $ENVF — paste the SlowGuess write token first"; exit 1; }
source "$(conda info --base)/etc/profile.d/conda.sh"
conda activate "$WORK/conda/abforge_vllm"
# whoami via env-token only; never echo the token itself.
python - <<'PY'
import os
from huggingface_hub import HfApi
tok = os.environ["HF_TOKEN"]
info = HfApi().whoami(token=tok)
name = info.get("name")
# token write permission (varies by token type)
auth = (info.get("auth") or {}).get("accessToken") or {}
role = auth.get("role") or info.get("auth", {}).get("type")
print(f"HF token belongs to : {name}")
print(f"token role/scope : {role}")
orgs = [o.get('name') for o in info.get('orgs', [])]
print(f"orgs : {orgs}")
print("OK: can target SlowGuess namespace" if name == "SlowGuess" else
"WARNING: token is NOT SlowGuess — uploads to SlowGuess/* will 403")
PY