name: Python Examples
on:
pull_request:
types: [opened, ready_for_review, synchronize]
push:
branches:
- main
jobs:
examples:
name: Run Python examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache MiniLM embedder weights
uses: actions/cache@v4
with:
path: ~/.cache/prollytree/embedders
key: minilm-l6-v2-main-v1
restore-keys: |
minilm-l6-v2-
- name: Build wheel (with all features)
uses: PyO3/maturin-action@v1
env:
PYO3_CROSS_PYTHON_VERSION: "3.11"
with:
target: x86_64
args: --release --out dist --features python,git,sql,rocksdb_storage,proximity,proximity_text --interpreter python3.11
sccache: 'true'
manylinux: 2_28
rust-toolchain: stable
before-script-linux: |
# librocksdb-sys needs clang for bindgen + a C++ toolchain. Mirrors
# the install in python.yml.
if command -v yum >/dev/null 2>&1; then
yum install -y clang gcc gcc-c++ glibc-devel
elif command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y --no-install-recommends clang g++ libc6-dev
fi
- name: Configure git identity
run: |
git config --global user.name "CI Examples"
git config --global user.email "ci-examples@example.com"
git config --global init.defaultBranch main
- name: Install wheel
run: |
python -m pip install --upgrade pip
WHEEL=$(ls dist/prollytree-*-cp38-abi3-manylinux*_x86_64.whl | head -1)
echo "Installing $WHEEL"
python -m pip install --force-reinstall "$WHEEL"
- name: Verify install + feature flags
run: |
python -c "import prollytree as p; \
print('proximity_available =', p.proximity_available); \
print('proximity_text_available=', p.proximity_text_available); \
print('sql_available =', p.sql_available); \
print('git_available =', p.git_available); \
print('namespaced_available =', p.namespaced_available)"
- name: Run examples
run: |
set -e
# Run from /tmp so examples don't pollute the workspace and don't pick
# up the repo's pyproject.toml as their CWD (matches local convention).
cd /tmp
python "$GITHUB_WORKSPACE/python/examples/basic_usage.py"
python "$GITHUB_WORKSPACE/python/examples/sql_example.py"
python "$GITHUB_WORKSPACE/python/examples/merge_example.py"
python "$GITHUB_WORKSPACE/python/examples/namespaced_example.py"
python "$GITHUB_WORKSPACE/python/examples/text_index_example.py"