Skip to content

Commit

Permalink
add build-and-run.sh to python relay server
Browse files Browse the repository at this point in the history
  • Loading branch information
leoromanovsky committed Dec 17, 2024
1 parent 3454761 commit 041a8a8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package-testing/python-sdk-relay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Post test case files to this server and check the results against what's expected.

## Build and run

```shell
./build-and-run.sh
```

## Running locally with Docker

Build the docker image:
Expand Down
43 changes: 43 additions & 0 deletions package-testing/python-sdk-relay/build-and-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

# Set default values for vars

: "${SDK_REF:=main}"
: "${SDK_RELAY_HOST:=localhost}"
: "${SDK_RELAY_PORT:=4000}"
SDK="https://github.com/Eppo-exp/eppo-multiplatform.git"

# checkout the specified ref of the SDK repo, build it, and then insert it into vendors here.
rm -rf tmp
mkdir -p tmp

echo "Cloning ${SDK}@${SDK_REF}"
git clone -b ${SDK_REF} --depth 1 --single-branch ${SDK} tmp || ( echo "Cloning repo failed"; exit 1 )

# Run the poller
python3 -m venv tmp/.venv
source tmp/.venv/bin/activate
pip install maturin

# Build the wheel file in tmp directory
maturin build --release --out tmp/dist --find-interpreter --manifest-path ./tmp/python-sdk/Cargo.toml

# Get Python version and find matching wheel
PYTHON_VERSION=$(python3 -c 'import sys; print(f"cp{sys.version_info.major}{sys.version_info.minor}")')
echo "Looking for wheel for Python version: ${PYTHON_VERSION}"

WHEEL_FILE=$(find tmp/dist -name "eppo_server_sdk-*-${PYTHON_VERSION}-*.whl" | head -n 1)
echo "Found wheel file: ${WHEEL_FILE}"

if [ -z "$WHEEL_FILE" ]; then
echo "Error: Wheel file not found for Python version ${PYTHON_VERSION}"
echo "Available wheels:"
ls tmp/dist
exit 1
fi

pip install "${WHEEL_FILE}"

echo "Listening on port ${SDK_RELAY_PORT}"

python3 -m http.server ${SDK_RELAY_PORT}

0 comments on commit 041a8a8

Please sign in to comment.