Skip to main content

anyserve Python Bindings

This package provides high-performance Python bindings for AnyServe. Its transport implementation comes from crates/anyserve-client; the public package adds role-specific facades and higher-level worker helpers on top.

Install

From PyPI:

pip install anyserve-runtime

The published distribution name is anyserve-runtime, while the import package remains:

import anyserve

From a local wheel:

pip install target/wheels/anyserve_runtime-*.whl

From local source:

pip install ./clients/python

Source installs build the native extension locally, so they require a working Rust toolchain on PATH. Inside this repository, mise exec -- ... provides the expected toolchains.

The top-level AnyserveClient exposes the generic control-plane surface and also offers role-specific views through submitter() and worker().

It also includes a high-level worker API for function-style handlers:

from anyserve import serve, worker


@worker(
    interface="demo.echo.v1",
    attributes={"runtime": "python"},
    capacity={"slot": 1},
    codec="bytes",
)
def echo(payload: bytes) -> bytes:
    return payload


serve(echo, endpoint="http://127.0.0.1:50052")

Examples use endpoint strings like http://127.0.0.1:50052 because the bindings connect through a gRPC channel URI. This is not a REST base URL.

API Surface

  • submit_job
  • watch_job
  • list_jobs
  • get_job
  • cancel_job
  • get_attempt
  • list_attempts
  • register_worker
  • heartbeat_worker
  • poll_lease
  • renew_lease
  • report_event
  • complete_lease
  • fail_lease
  • open_stream
  • get_stream
  • list_streams
  • close_stream
  • push_frames
  • pull_frames

watch_job(...) and pull_frames(...) return iterators so the Python API preserves streaming semantics instead of materializing the full stream into a list.

It also includes two convenience constructors:

  • inline_object(...)
  • uri_object(...)

And high-level worker helpers:

  • worker(...)
  • serve(...)
  • get_handler_spec(...)

Local Development

Build and install from local source into the active environment:

pip install ./clients/python

Or install the extension directly into the active environment through maturin:

python3 -m pip install --user maturin
python3 -m maturin develop --manifest-path clients/python/Cargo.toml

Live end-to-end validation:

mise run python-sdk-e2e

PyPI Publishing

The repository is set up to publish the Python package through PyPI Trusted Publishing.

  • PyPI project name: anyserve-runtime
  • GitHub repository: anyserve/anyserve
  • Workflow path: .github/workflows/python-publish.yml
  • GitHub environment: pypi

For the first release, create a pending Trusted Publisher for anyserve-runtime on PyPI, then run the publish workflow or push a v* tag.

Example

High-level worker example:

from anyserve import serve, worker


@worker(
    interface="demo.echo.v1",
    attributes={"runtime": "python"},
    capacity={"slot": 1},
    codec="bytes",
)
def echo(payload: bytes) -> bytes:
    return payload


serve(echo, endpoint="http://127.0.0.1:50052")

Low-level submitter example:

from anyserve import AnyserveClient, FRAME_DATA

client = AnyserveClient("http://127.0.0.1:50052")
# Assumes the control plane and a compatible worker are already running.

job = client.submit_job(
    interface_name="demo.echo.v1",
    required_attributes={"runtime": "demo"},
    required_capacity={"slot": 1},
)

stream = client.open_stream(job["job_id"], "input.default")
client.push_frames(
    stream["stream_id"],
    [(FRAME_DATA, b"hello from python", {})],
)
client.close_stream(stream["stream_id"])

for event in client.watch_job(job["job_id"]):
    print(event["kind"], event["metadata"])

Metadata

Release files for anyserve-runtime 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anyserve-runtime 0.4.0
File Size Uploaded
anyserve_runtime-0.4.0.tar.gz 47.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anyserve-runtime 0.4.0
File Interpreter ABI Platform
anyserve_runtime-0.4.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details

Total release size: 2.3 MB

Release files / anyserve_runtime-0.4.0.tar.gz

Download URL anyserve_runtime-0.4.0.tar.gz
Size 47.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8c6664a713af7be8cb1e189b81f2f0bcd61958abcfc2f21cf2b062818efece44
BLAKE2b-256 checksum
How to use checksums
d59300dc1263ce721d963bd9cb1ae0e74e81d2eafd9210a3740975dbb62710cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 5, 2026.

Transparency log

Release files / anyserve_runtime-0.4.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL anyserve_runtime-0.4.0-cp312-abi3-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d518b7ef012164b631771ee5a2bc8ba0045f7358b785e85e5369df7f7cc1ab90
BLAKE2b-256 checksum
How to use checksums
406884463aa1a17af5579da3f6b100a8af29aec83e54fbe8346aea25d24b69ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page