andito's picture
andito HF Staff
wait.sh: read the job stage from the current hf CLI output
268f053 verified
Raw History Blame Contribute Delete
618 Bytes
#!/bin/zsh
# wait.sh job... : wait until every job reaches a terminal stage, then print key log lines
export HF_HUB_DISABLE_EXPERIMENTAL_WARNING=1
stage() { hf jobs inspect $1 2>/dev/null | grep -oE "[\"']stage[\"']: [\"'][A-Z_]+" | grep -oE "[A-Z_]+$"; }
while true; do
done_count=0
for j in "$@"; do case $(stage $j) in COMPLETED|ERROR|CANCELED|DELETED|TIMEOUT) done_count=$((done_count+1));; esac; done
[ $done_count -eq $# ] && break
sleep 30
done
for j in "$@"; do echo "== $j $(stage $j)"; hf jobs logs $j 2>&1 | grep -E '^\$|^final|^\{"model|Error|Traceback|error|pushed' | cut -c1-300 | tail -14; done