41 lines
2.3 KiB
Bash
Executable File
41 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
[[ ${1:-} == --go && $(hostname) == athena ]] || { echo 'Usage on Athena: repeat-go.sh --go' >&2; exit 2; }
|
|
cd /opt/mike-ai/experiments/ornith15-ab
|
|
OUT=/data/benchmarks/ornith15-ab
|
|
ORIGINAL=$(docker ps --format '{{.Names}}' | sed -n 's/^mike-ai-llama-\(fast\|medium\|large\|ultra\|uncensored\)$/\1/p')
|
|
[[ $(wc -w <<<"$ORIGINAL") == 1 ]] || exit 1
|
|
WHISPER_WAS_RUNNING=false
|
|
docker inspect -f '{{.State.Running}}' mike-ai-whisper 2>/dev/null | grep -qx true && WHISPER_WAS_RUNNING=true
|
|
TTS_WAS_RUNNING=false
|
|
docker inspect -f '{{.State.Running}}' mike-ai-qwen3-tts 2>/dev/null | grep -qx true && TTS_WAS_RUNNING=true
|
|
controller() {
|
|
docker exec mike-ai-profile-controller python3 -c '
|
|
import os, sys, urllib.request
|
|
token=os.environ.get("CONTROLLER_TOKEN","").strip() or open(os.environ.get("CONTROLLER_TOKEN_FILE","/run/secrets/controller-token"),encoding="utf-8").read().strip()
|
|
req=urllib.request.Request("http://127.0.0.1:8090"+sys.argv[1],data=b"{}",headers={"Authorization":"Bearer "+token,"Content-Type":"application/json"},method="POST")
|
|
print(urllib.request.urlopen(req,timeout=180).read().decode())
|
|
' "$1"
|
|
}
|
|
finish() {
|
|
local rc=$?; trap - EXIT HUP INT TERM
|
|
./case.sh fast stop || true
|
|
if $TTS_WAS_RUNNING; then docker start mike-ai-qwen3-tts >/dev/null 2>&1 || true; fi
|
|
if $WHISPER_WAS_RUNNING; then docker start mike-ai-whisper >/dev/null 2>&1 || true; fi
|
|
controller "/profiles/$ORIGINAL/activate" || true
|
|
exit "$rc"
|
|
}
|
|
trap finish EXIT HUP INT TERM
|
|
wait_health() { for ((i=0;i<450;i++)); do curl -fsS --max-time 2 "$1/health" >/dev/null 2>&1 && return 0; sleep 2; done; return 1; }
|
|
controller /profiles/fast/activate
|
|
ip=$(docker inspect mike-ai-llama-fast --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
|
|
wait_health "http://$ip:8080"
|
|
python3 repeat_critical.py --base "http://$ip:8080" --model qwen-fast --output "$OUT/repeat-qwen-fast.json" --go
|
|
controller /inference/stop
|
|
if $WHISPER_WAS_RUNNING; then docker stop mike-ai-whisper >/dev/null; fi
|
|
if $TTS_WAS_RUNNING; then docker stop mike-ai-qwen3-tts >/dev/null; fi
|
|
./case.sh fast create
|
|
./case.sh fast start --go
|
|
wait_health http://127.0.0.1:5007
|
|
python3 repeat_critical.py --base http://127.0.0.1:5007 --model ornith15-test --output "$OUT/repeat-ornith-fast.json" --go
|