Auto-generated, fully typed Python client for the Malloy Publisher REST API.
pip install malloy-publisher-sdk # once published on PyPIFor local development against the monorepo:
cd packages/python-client
uv venv .venv # create virtual env (requires `uv`)
source .venv/bin/activate
uv pip install -e ".[test]" # editable install with test extrasfrom malloy_publisher_sdk import Client, errors
from malloy_publisher_sdk.api.projects import list_projects
client = Client(base_url="http://localhost:4000/api/v0")
try:
projects = list_projects.sync(client=client)
for proj in projects:
print(proj.name, proj.resource)
except errors.ApiError as exc:
print(exc.status_code, exc.body)import asyncio
from malloy_publisher_sdk import Client
from malloy_publisher_sdk.api.projects import list_projects
async def main():
async with Client(base_url="http://localhost:4000/api/v0") as client:
projects = await list_projects.asyncio(client=client)
print([p.name for p in projects])
asyncio.run(main())When the OpenAPI spec (api-doc.yaml) changes, run the helper script and commit the diff:
cd packages/python-client
scripts/build-python-sdk.shThe script performs:
- Spec validation
- Code generation via openapi-python-client
- Version synchronization
- Formatting, linting, type-checking
- Test execution
To build the Python package for distribution:
# Build only (for testing)
./scripts/build-package.sh
# Or build as part of SDK generation
BUILD_PACKAGE=true ./scripts/build-python-sdk.shThis creates wheel and source distributions in the dist/ directory.
The package version is managed in pyproject.toml. Update the version there and run the build script to synchronize it across all files.
Pull requests welcome! Make sure ./scripts/build-python-sdk.sh passes before opening a PR.
For packaging changes, also verify:
./scripts/build-package.sh # Test package building
pip install dist/*.whl # Test local installationMIT © Malloy Data