#!/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 900 --reset-on-timeout -- bash code/scripts/device_server_smoke.sh [port] [out.json] # # Env: the server's MINILM_* configuration (defaults: engine mk, ETH dispatch). Exit code: the smoke test's. set -u PORT="${1:-20123}" OUT="${2:-}" HERE="$(cd "$(dirname "$0")" && pwd)" CODE="$(cd "$HERE/.." && pwd)" # run outside code/ (tt-metal writes generated/ into the CWD); the package comes from PYTHONPATH RUN="${MINILM_RUN_DIR:-${TMPDIR:-/tmp}/minilm-server-smoke}" mkdir -p "$RUN" && cd "$RUN" export PYTHONPATH="$CODE${PYTHONPATH:+:$PYTHONPATH}" export TT_MESH_SHAPE="${TT_MESH_SHAPE:-1x1}" python -u -m uvicorn --host 127.0.0.1 --port "$PORT" --lifespan on tt_minilm.server.app:app & SRV=$! stop() { kill -TERM "$SRV" 2>/dev/null; for _ in $(seq 1 60); do kill -0 "$SRV" 2>/dev/null || break; sleep 1; done; } trap stop EXIT python3 "$HERE/../tt_minilm/server/smoke_test.py" --url "http://127.0.0.1:$PORT" --wait 600 \ --expect-engine "${MINILM_ENGINE:-mk}" ${OUT:+--out "$OUT"}