Python worker framework for the Verda inference orchestrator
Project description
Verda IO
Python worker framework for the Verda Inference Orchestrator.
Installation
pip install verda-io
Or with uv:
uv add verda-io
Quick Start
Create a worker with initialization and prediction functions:
import verda_io
@verda_io.initialize
def setup():
"""Called once at startup. Load your model here."""
global model
model = load_my_model()
@verda_io.predict
def predict(payload: bytes) -> bytes:
"""Called for each inference request."""
result = model(payload)
return result
Run it with the Verda server:
verda-io run server -c config.yaml
Or run the worker directly:
python -m verda_io main.py --socket /tmp/verda-io.data.sock --id worker-1
Ordered Initialization
When your startup sequence requires specific ordering, use @verda_io.initialize with an order parameter. Functions run in ascending order:
import verda_io
@verda_io.initialize(0)
def load_tokenizer():
global tokenizer
tokenizer = AutoTokenizer.from_pretrained("model-name")
@verda_io.initialize(1)
def load_model():
global model
model = AutoModelForCausalLM.from_pretrained("model-name")
@verda_io.initialize(2)
def warm_up():
model.generate(tokenizer("warm up", return_tensors="pt").input_ids)
Using @verda_io.initialize without an argument defaults to order 0. Multiple functions with the same order run in registration order.
Streaming Responses
Return a generator from your predict function to stream results:
@verda_io.predict
def predict(payload: bytes) -> bytes:
for token in model.generate_stream(payload):
yield token.encode()
API
@verda_io.initialize- Register a startup function (called once, supports ordering)@verda_io.predict- Register the prediction function (called per request, exactly one required)verda_io.run()- Start the worker loop programmatically
How It Works
The verda_io package connects to the Verda server via Unix domain sockets using a binary protocol (MessagePack + 12-byte headers). Initialization functions run once at startup in order, and @verda_io.predict is called for each inference request routed by the server.
Requirements
- Python 3.10+
- Linux or macOS (Unix domain sockets required)
License
Apache License 2.0
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 verda_io-0.1.0.tar.gz.
File metadata
- Download URL: verda_io-0.1.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77a427d3b007df9c2305f4449f41e61dee0a9587b3b200dcd54b8c19eb618d4d
|
|
| MD5 |
29e303209f0a0b442c8e31453cc31917
|
|
| BLAKE2b-256 |
b55ac454e1ea9bad282c62870d52b4a8a56dad782dc13533e6a66cfec0c0534c
|
File details
Details for the file verda_io-0.1.0-py3-none-any.whl.
File metadata
- Download URL: verda_io-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99e58d0e7c5c65f296707840d2705c17348d5ed8657eac164f4efb216ffffc23
|
|
| MD5 |
da7ff8afce033c6cd5d8a4dab97cabcf
|
|
| BLAKE2b-256 |
92aabc2c6c412ae5d0291a1fce213fde7add27367185dd2f4a4e7bdb0b82f281
|