#!/usr/bin/env bash
# Window-length test: vlaai_ws on mat with 7-s and 3-s input windows (default 5 s = results/vlaai_ws__mat.json).
# Same causal read-out (<= 0.75 s future), so only the amount of PAST context changes.
cd "$(dirname "$0")/.."
PY=../../.venv/bin/python
QLOG=logs/queue_win.log
echo "$(date '+%F %T') queue win started" | tee -a "$QLOG"
for spec in "vlaai_ws mat 7" "vlaai_ws mat 3"; do
  set -- $spec; dec=$1; prep=$2; w=$3; exp="${dec}__${prep}_w${w}s"
  [[ -f results/$exp.json ]] && { echo "$(date '+%F %T') skip $exp" | tee -a "$QLOG"; continue; }
  echo "$(date '+%F %T') START $exp" | tee -a "$QLOG"
  if $PY run_experiment.py --decoder $dec --prep $prep --tag _w${w}s --window-s $w < /dev/null >> logs/$exp.stdout 2>&1; then
    rm -f results/$exp.FAILED
    echo "$(date '+%F %T') DONE  $exp: $(grep 'MEAN over' logs/$exp.log | tail -1 | cut -d' ' -f3-)" | tee -a "$QLOG"
  else
    touch results/$exp.FAILED; echo "$(date '+%F %T') FAILED $exp" | tee -a "$QLOG"
  fi
  $PY summarize.py > /dev/null 2>&1 || true
done
echo "$(date '+%F %T') queue win finished" | tee -a "$QLOG"
