-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-python-to-lean.sh
More file actions
executable file
·52 lines (48 loc) · 1.81 KB
/
Copy pathrun-python-to-lean.sh
File metadata and controls
executable file
·52 lines (48 loc) · 1.81 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# Copyright © 2026, Riley Betts Ltd (rileybetts.ai)
# Python interop client → Lean interop server (replaces Go→Lean matrix).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
PORT="${GRPC_PORT:-10000}"
CASES=(
empty_unary large_unary status_code_and_message custom_metadata cancel_after_begin
server_streaming client_streaming ping_pong empty_stream
cancel_after_first_response special_status_message unimplemented_method unimplemented_service
timeout_on_sleeping_server
client_compressed_unary server_compressed_unary server_compressed_streaming
)
# Note: cacheable_unary omitted (needs caching proxy + CacheableUnaryCall / GET).
cd "$ROOT"
if [[ ! -d .venv-interop ]]; then
python3 -m venv .venv-interop
fi
# shellcheck disable=SC1091
source .venv-interop/bin/activate
pip install -q --upgrade pip
pip install -q -r python_interop/requirements.txt
# Always regenerate stubs with the pinned grpcio-tools so gencode matches runtime.
python -m grpc_tools.protoc -I python_interop/proto \
--python_out=python_interop --grpc_python_out=python_interop \
python_interop/proto/empty.proto python_interop/proto/messages.proto \
python_interop/proto/test.proto
lake build interopServer
fuser -k "${PORT}/tcp" 2>/dev/null || true
GRPC_PORT="$PORT" ./.lake/build/bin/interopServer > /tmp/lean-grpc-py-interop.log 2>&1 &
pid=$!
trap 'kill "$pid" 2>/dev/null || true' EXIT
sleep 1
export PYTHONPATH="$ROOT/python_interop${PYTHONPATH:+:$PYTHONPATH}"
fail=0
for c in "${CASES[@]}"; do
echo "== python → lean: $c"
if ! timeout 60 python python_interop/client.py \
--server_host=127.0.0.1 --server_port="$PORT" --test_case="$c"; then
echo "FAIL $c"
fail=$((fail + 1))
fi
done
if [[ "$fail" -ne 0 ]]; then
echo "run-python-to-lean FAILED ($fail)"
exit 1
fi
echo "run-python-to-lean OK"