forensics-grpo / code /dl_retry.sh
sdzt's picture
Add root download helper scripts
fe47d73 verified
Raw
History Blame Contribute Delete
969 Bytes
#!/bin/bash
# Resilient HF download with retries and low concurrency
set -u
cd /mnt/local-fast/zhangt
LOG=/mnt/local-fast/zhangt/hf_download.log
MAX_ATTEMPTS=200
attempt=0
while true; do
attempt=$((attempt+1))
echo "===== attempt $attempt $(date -Is) =====" >> "$LOG"
HF_HOME=/mnt/local-fast/zhangt/.cache/huggingface \
hf download ActivityForensics/ActivityForensics \
--repo-type dataset \
--include 'video/*' \
--cache-dir /mnt/local-fast/zhangt/.cache/huggingface/hub \
--max-workers 4 >> "$LOG" 2>&1
rc=$?
echo "===== attempt $attempt exit=$rc $(date -Is) =====" >> "$LOG"
if [ $rc -eq 0 ]; then
echo "DOWNLOAD OK" >> "$LOG"
exit 0
fi
if [ $attempt -ge $MAX_ATTEMPTS ]; then
echo "GIVE UP after $attempt attempts" >> "$LOG"
exit 1
fi
# exponential backoff capped at 5 min
sleep_s=$(( attempt*30 < 300 ? attempt*30 : 300 ))
echo "sleeping ${sleep_s}s before retry" >> "$LOG"
sleep "$sleep_s"
done