DragMesh-3-Scene / wait_workers.sh
Neptune-T's picture
Add files using upload-large-folder tool
327ef01 verified
Raw History Blame Contribute Delete
1.81 kB
#!/usr/bin/env bash
# Server-side watcher: waits for all 3 batch workers (A/B/C) to finish,
# then launches pipeline_after_batch.sh (export + trajectories), then
# render_all.py in docker. Logs to ~/scene/batch_logs/wait_workers.log
set -u
LOG_DIR="$HOME/scene/batch_logs"
LOG="$LOG_DIR/wait_workers.log"
log() { echo "$(date "+%F %T") $*" >> "$LOG"; }
log "wait_workers started"
# ---- 1. wait for all workers ----
for i in $(seq 1 2400); do # 2400 x 60s = 40h
if [ -f "$LOG_DIR/parallel_A.done" ] && [ -f "$LOG_DIR/parallel_B.done" ] && [ -f "$LOG_DIR/parallel_C.done" ]; then
log "all workers done (iter $i), launching pipeline"
setsid nohup bash /home/zhanghao/scene/pipeline_after_batch.sh > "$LOG_DIR/pipeline_run.log" 2>&1 < /dev/null &
log "pipeline launched"
break
fi
sleep 60
done
if [ "$i" -ge 2400 ]; then
log "TIMEOUT waiting for workers - proceeding anyway"
setsid nohup bash /home/zhanghao/scene/pipeline_after_batch.sh > "$LOG_DIR/pipeline_run.log" 2>&1 < /dev/null &
log "pipeline launched (after timeout)"
fi
# ---- 2. wait for pipeline.done ----
for i in $(seq 1 1800); do # 1800 x 60s = 30h
if [ -f "$LOG_DIR/pipeline.done" ]; then
log "pipeline.done: $(cat "$LOG_DIR/pipeline.done" | tr -d '\n')"
break
fi
sleep 60
done
if [ ! -f "$LOG_DIR/pipeline.done" ]; then log "TIMEOUT waiting for pipeline.done"; fi
# ---- 3. launch render_all in docker ----
log "launching render_all.py"
setsid nohup docker run --rm --gpus all -e MUJOCO_GL=egl \
-v /home/zhanghao/scene/scenesmith_full:/app \
-v /home/zhanghao/scene/trajectories:/app/trajectories \
scenesmith:latest python /app/render_all.py \
> "$LOG_DIR/render_all.log" 2>&1 < /dev/null &
log "render_all launched"
log "wait_workers DONE"