-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add build-and-run.sh to python relay server (#98)
* add build-and-run.sh to python relay server * refactor dockerfile to build wheel * requirements * SDK_RELAY_HOST * hardcode to 0.0.0.0 * python fixes and run in venv * do not hardcore url * only works with 0.0.0.0
- Loading branch information
1 parent
1fa74e4
commit 5c2b812
Showing
8 changed files
with
64 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SDK_REF=main | ||
SDK_RELAY_HOST=localhost | ||
SDK_RELAY_PORT=4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
bin | ||
lib | ||
venv | ||
.venv | ||
tmp |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/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" | ||
|
||
# Create a persistent virtual environment. | ||
if [ ! -d ".venv" ]; then | ||
python3 -m venv .venv | ||
fi | ||
source .venv/bin/activate | ||
|
||
# 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 ) | ||
|
||
# TODO: Refactor this into a `build.sh` script that resides in the SDK repo. | ||
|
||
# install dependencies | ||
|
||
pip install maturin | ||
pip install -r requirements.txt | ||
|
||
# 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}" | ||
|
||
# cleanup | ||
rm -rf tmp | ||
|
||
# start the relay server | ||
echo "Listening on port ${SDK_RELAY_HOST}:${SDK_RELAY_PORT}" | ||
python3 src/server.py |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
flask | ||
eppo-server-sdk==4.1.0 | ||
# eppo-server-sdk installed from local wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters