File size: 2,218 Bytes
868a5eb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #!/bin/bash
#SBATCH --job-name=droid_finalize_v2
#SBATCH --partition=c6-128-main
#SBATCH --cpus-per-task=2
#SBATCH --mem=8G
#SBATCH --time=12:00:00
#SBATCH --output=/home/wujiayir/robot_tools/droid/out/slurm/finalize_v2_%j.log
# Runs after the pipeline arrays (scripts/sbatch_pipeline.sh) ended:
# 1. build out/index_v2.jsonl (+ out/index_v2.summary.json, data/missing_eps_v2.txt)
# 2. retry the missing / failed episodes as a new pipeline array (sbatch --wait), up to RETRY_ROUNDS times
# 3. rebuild the index; print the summary
# Nothing under out/ is deleted (the old frame-PNG cleanup is opt-in: CLEANUP_FRAMES=1).
# sbatch scripts/finalize_batch.sh
# sbatch --dependency=afterany:<pipeline array job id> scripts/finalize_batch.sh
# Env: MANIFEST (default data/manifest_v2.txt), OUT_INDEX (default out/index_v2.jsonl), MISSING (default
# data/missing_eps_v2.txt), RETRY_ROUNDS (default 1), THROTTLE (default 40); GT_POLICY / FORCE / REFINE_ARGS ...
# are passed through to the retry array (sbatch exports the environment).
set -u
DROID=/home/wujiayir/robot_tools/droid
PY=/home/wujiayir/miniconda3/envs/droid/bin/python
cd "$DROID/scripts"
abs() { case "$1" in /*) echo "$1" ;; *) echo "$DROID/$1" ;; esac; }
MF=$(abs "${MANIFEST:-data/manifest_v2.txt}")
IDX=$(abs "${OUT_INDEX:-out/index_v2.jsonl}")
MISS=$(abs "${MISSING:-data/missing_eps_v2.txt}")
[ -f "$MF" ] || $PY build_index.py --make-manifest
INDEX="$PY build_index.py --manifest $MF --out $IDX --missing $MISS"
echo "== index pass 1 $(date -u)"
$INDEX
ROUND=0
while [ $ROUND -lt ${RETRY_ROUNDS:-1} ] && [ -s "$MISS" ]; do
ROUND=$((ROUND + 1))
N=$(wc -l < "$MISS")
cp "$MISS" "${MISS%.txt}.round${ROUND}.txt"
echo "== retry round $ROUND: $N episodes (array, throttle ${THROTTLE:-40}) $(date -u)"
JOB=$(MANIFEST="${MISS%.txt}.round${ROUND}.txt" sbatch --parsable --wait \
--array=0-$((N - 1))%${THROTTLE:-40} "$DROID/scripts/sbatch_pipeline.sh") || { echo "retry submission failed"; break; }
echo "== retry array $JOB finished $(date -u)"
$INDEX
done
if [ "${CLEANUP_FRAMES:-0}" = "1" ]; then bash "$DROID/scripts/cleanup_frames.sh"; fi
echo "== final index $(date -u)"
$INDEX
echo "FINALIZE_DONE $(date -u)"
|