#!/usr/bin/env bash
# Inference-only replay of the exported A9M folder, as the platform does; then copy it to the competition repo and zip it.
# Log: replay_a9m.log
cd "$(dirname "$0")"
OUT="$PWD/sleep_onset/outputs/CNN-feat-GRU-Ensemble-A9M"
DEST=/root/disk_3tb/Neural_Interfaces_2026_Track_3_Sleep_Onset/2026-competition/tracks/sleep_onset/outputs
COMPET_SUBMISSION_DIR="$OUT" /root/miniconda3/bin/benchopt run sleep_onset -d Interaxon2026Muse -s "$OUT/submission.py" 2>&1 | grep --line-buffered -v "^warning" | tee replay_a9m.log
echo "EXIT CODE ${PIPESTATUS[0]}" | tee -a replay_a9m.log
/root/miniconda3/bin/python show_score.py 2>&1 | tee -a replay_a9m.log
mkdir -p "$DEST/CNN-feat-GRU-Ensemble-A9M" && cp "$OUT/submission.py" "$OUT/weights.pt" "$DEST/CNN-feat-GRU-Ensemble-A9M/"
(cd "$DEST/CNN-feat-GRU-Ensemble-A9M" && rm -f ../CNN-feat-GRU-Ensemble-A9M.zip && /root/miniconda3/bin/python -c "import zipfile; z=zipfile.ZipFile('../CNN-feat-GRU-Ensemble-A9M.zip','w',zipfile.ZIP_DEFLATED); [z.write(f) for f in ('submission.py','weights.pt')]; z.close()")
unzip -l "$DEST/CNN-feat-GRU-Ensemble-A9M.zip" | tee -a replay_a9m.log
