Skip to content

Fixes

Fixes #876

name: Test Python Client Package
# Validates the Python REST client package build and import surface.
permissions:
contents: read
# Cancel any preceding run on the pull request after a new commit is pushed.
concurrency:
# Use a stable key across event types (push vs pull_request):
# - PRs: key by PR number
# - Pushes: key by branch ref (prefer head_ref when present)
group: test-python-client-package-${{ github.event.pull_request.number || github.head_ref || github.ref }}
# Don't cancel if running on a push to the main branch.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
jobs:
test-python-client-package:
name: Test Python Client Package (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.14"]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv build
- name: Build Python client package
shell: bash
run: |
uv build --project packages/common -o dist/
uv build --project packages/client -o dist/
python -c "import pathlib, sys; d=sorted(pathlib.Path('dist').glob('memmachine_common-*.whl')); [print(p.name) for p in d]; sys.exit(1 if not d else 0)"
python -c "import pathlib, sys; d=sorted(pathlib.Path('dist').glob('memmachine_client-*.whl')); [print(p.name) for p in d]; sys.exit(1 if not d else 0)"
- name: Install Python client package
shell: bash
run: |
set -eo pipefail
whl_name=$(python -c "import pathlib; d=sorted(pathlib.Path('dist').glob('memmachine_client-*.whl')); print(d[0] if d else '')")
if [ -z "$whl_name" ]; then
echo "No client wheel found" >&2
exit 1
fi
python -m pip install --find-links dist/ "$whl_name"
- name: Test Python client package imports
shell: bash
run: |
set -eo pipefail
python -c "
from memmachine_client import MemMachineClient, Memory, Project
from memmachine_common.api import MemoryType
print('All imports successful')
print(f'Python version: {__import__(\"sys\").version}')
print(f'MemoryType.Semantic = {MemoryType.Semantic.value}')
print(f'MemoryType.Episodic = {MemoryType.Episodic.value}')
print(f'MemMachineClient class: {MemMachineClient}')
print(f'Memory class: {Memory}')
print(f'Project class: {Project}')
"
- name: Test Python client package basic functionality
shell: bash
run: |
set -eo pipefail
python -c "
from memmachine_client import MemMachineClient
from memmachine_common.api import MemoryType
# Test client instantiation
client = MemMachineClient(base_url='http://localhost:8080')
print('Client instantiation successful')
# Test MemoryType enum
assert MemoryType.Semantic.value == 'semantic'
assert MemoryType.Episodic.value == 'episodic'
print('MemoryType enum values correct')
# Test that client has expected methods
assert hasattr(client, 'get_project')
assert hasattr(client, 'create_project')
assert hasattr(client, 'close')
print('Client has expected methods')
"
- name: Verify Python client package structure
shell: bash
run: |
set -eo pipefail
python -c "
import memmachine_client
import memmachine_common.api
# Check that modules exist
assert hasattr(memmachine_common.api, 'MemoryType')
assert hasattr(memmachine_client, 'MemMachineClient')
assert hasattr(memmachine_client, 'Memory')
assert hasattr(memmachine_client, 'Project')
print('Package structure verified')
"