#!/usr/bin/env bash
# Reliability-weighted HMM evidence on saved runs: base config (4 seeds) + onset config (all seeds as they finish).
cd "$(dirname "$0")/.."
PY=../../.venv/bin/python
QLOG=logs/queue_reliability.log
BASE="vlaai_ws__mat_aug_cluster vlaai_ws__mat_aug_cluster_s1 vlaai_ws__mat_aug_cluster_s2 vlaai_ws__mat_aug_cluster_s3"
ON="vlaai_ws__mat_aug_cluster_onset vlaai_ws__mat_aug_cluster_onset_s1"
echo "$(date '+%F %T') START reliability on onset (2 seeds) + base (4 seeds)" | tee -a "$QLOG"
$PY reliability.py $ON $BASE >> logs/reliability.stdout 2>&1 || echo "$(date '+%F %T') FAILED (see logs/reliability.stdout)" | tee -a "$QLOG"
for e in vlaai_ws__mat_aug_cluster_onset_s2 vlaai_ws__mat_aug_cluster_onset_s3; do   # wait for the new onset seeds
  until [[ -f results/$e.json || -f results/$e.FAILED ]]; do sleep 120; done
  [[ -f results/$e.json ]] && $PY reliability.py $e >> logs/reliability.stdout 2>&1
done
$PY summarize.py > /dev/null 2>&1 || true
echo "$(date '+%F %T') queue reliability finished" | tee -a "$QLOG"
