File size: 1,331 Bytes
f882f26 | 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 900 --reset-on-timeout -- bash code/scripts/device_server_smoke.sh [port] [out.json]
#
# Env: the server's LAYA_* configuration (defaults: profile english, engine mk, ETH dispatch; LAYA_WEIGHTS_DIR for a local snapshot). Exit code: the smoke test's.
set -u
PORT="${1:-20223}"
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="${LAYA_RUN_DIR:-${TMPDIR:-/tmp}/laya-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_laya.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_laya/server/smoke_test.py" --url "http://127.0.0.1:$PORT" --wait 900 \
--expect-engine "${LAYA_ENGINE:-mk}" ${OUT:+--out "$OUT"}
|