Rust-backed Python package for AnyServe
Project description
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_jobwatch_joblist_jobsget_jobcancel_jobget_attemptlist_attemptsregister_workerheartbeat_workerpoll_leaserenew_leasereport_eventcomplete_leasefail_leaseopen_streamget_streamlist_streamsclose_streampush_framespull_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"])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anyserve_runtime-0.4.0.tar.gz.
File metadata
- Download URL: anyserve_runtime-0.4.0.tar.gz
- Upload date:
- Size: 47.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c6664a713af7be8cb1e189b81f2f0bcd61958abcfc2f21cf2b062818efece44
|
|
| MD5 |
9125b0d44e79c4b9dbefdd4a8d6eb6d2
|
|
| BLAKE2b-256 |
d59300dc1263ce721d963bd9cb1ae0e74e81d2eafd9210a3740975dbb62710cb
|
Provenance
The following attestation bundles were made for anyserve_runtime-0.4.0.tar.gz:
Publisher:
python-publish.yml on anyserve/anyserve
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyserve_runtime-0.4.0.tar.gz -
Subject digest:
8c6664a713af7be8cb1e189b81f2f0bcd61958abcfc2f21cf2b062818efece44 - Sigstore transparency entry: 1238979090
- Sigstore integration time:
-
Permalink:
anyserve/anyserve@bc96670c29450e35fe766ca1762171a39e3896cc -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/anyserve
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@bc96670c29450e35fe766ca1762171a39e3896cc -
Trigger Event:
push
-
Statement type:
File details
Details for the file anyserve_runtime-0.4.0-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: anyserve_runtime-0.4.0-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d518b7ef012164b631771ee5a2bc8ba0045f7358b785e85e5369df7f7cc1ab90
|
|
| MD5 |
75dd3a288e993a79158f723b32cbc9c8
|
|
| BLAKE2b-256 |
406884463aa1a17af5579da3f6b100a8af29aec83e54fbe8346aea25d24b69ed
|
Provenance
The following attestation bundles were made for anyserve_runtime-0.4.0-cp312-abi3-macosx_11_0_arm64.whl:
Publisher:
python-publish.yml on anyserve/anyserve
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyserve_runtime-0.4.0-cp312-abi3-macosx_11_0_arm64.whl -
Subject digest:
d518b7ef012164b631771ee5a2bc8ba0045f7358b785e85e5369df7f7cc1ab90 - Sigstore transparency entry: 1238979170
- Sigstore integration time:
-
Permalink:
anyserve/anyserve@bc96670c29450e35fe766ca1762171a39e3896cc -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/anyserve
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@bc96670c29450e35fe766ca1762171a39e3896cc -
Trigger Event:
push
-
Statement type: