File size: 1,259 Bytes
aa204f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Serving gate on the host (no container): start the HTTP server on the device, run server/smoke_test.py against it,
# stop the server. The server is the ONLY device process; run the whole script inside one device-lock window:
#
#   bin/devrun -t 1500 --reset-on-timeout -- bash code/scripts/device_server_smoke.sh [port] [out.json]
#
# Env: the server's GLMOCR_* configuration (defaults as tt-model.yaml: dec=mk, ETH dispatch); GLMOCR_MODEL_DIR = a
# local checkpoint directory. Exit code: the smoke test's.
set -u
PORT="${1:-20431}"
OUT="${2:-}"
HERE="$(cd "$(dirname "$0")" && pwd)"
CODE="$(cd "$HERE/.." && pwd)"
RUN="${GLMOCR_RUN_DIR:-${TMPDIR:-/tmp}/glmocr-server-smoke}"
mkdir -p "$RUN" && cd "$RUN"
export PYTHONPATH="$CODE${PYTHONPATH:+:$PYTHONPATH}"
export TT_MESH_SHAPE="${TT_MESH_SHAPE:-1x1}"
export GLMOCR_BACKEND="${GLMOCR_BACKEND:-device}"
python -u -m uvicorn --host 127.0.0.1 --port "$PORT" --lifespan on tt_glmocr.server.app:app &
SRV=$!
stop() { kill -TERM "$SRV" 2>/dev/null; for _ in $(seq 1 90); do kill -0 "$SRV" 2>/dev/null || break; sleep 1; done; }
trap stop EXIT
python3 "$CODE/tt_glmocr/server/smoke_test.py" --url "http://127.0.0.1:$PORT" --wait 1000 ${OUT:+--out "$OUT"}