Pie Client
Project description
Pie Python Client
A Python client for interacting with the Pie server.
Installation
pip install -e .
Quick Start
import asyncio
from pie import PieClient, ParsedPrivateKey
async def main():
async with PieClient("ws://127.0.0.1:8080") as client:
# Authentication is always required.
# If server auth is enabled, provide a valid private key:
key = ParsedPrivateKey.from_file("~/.ssh/id_ed25519")
await client.authenticate("username", key)
# If server auth is disabled, any username works without a key:
# await client.authenticate("any_username")
# Upload and launch a program
with open("my_program.wasm", "rb") as f:
await client.upload_program(f.read())
program_hash = "..." # blake3 hash of the wasm binary
instance = await client.launch_instance(program_hash)
# Interact with the instance
await instance.send("hello")
event, message = await instance.recv()
print(f"Received: {event.name} - {message}")
asyncio.run(main())
API Reference
PieClient
| Method | Description |
|---|---|
authenticate(username, private_key) |
Public key authentication (challenge-response) |
internal_authenticate(token) |
Token-based internal authentication |
upload_program(bytes) |
Upload a WASM program |
program_exists(hash) |
Check if program is uploaded |
launch_instance(hash, args, detached) |
Launch a program instance |
attach_instance(instance_id) |
Attach to a detached instance |
list_instances() |
List running instances |
terminate_instance(instance_id) |
Terminate an instance |
ping() |
Check server connectivity |
query(subject, record) |
Generic server query |
Instance
| Method | Description |
|---|---|
send(message) |
Send a string to the instance |
upload_blob(bytes) |
Upload binary data |
recv() |
Receive next event (returns (Event, data)) |
terminate() |
Request termination |
Event Types
| Event | Description |
|---|---|
Message |
Text message from instance |
Completed |
Instance finished successfully |
Aborted |
Instance was aborted |
Exception |
Instance raised an exception |
ServerError |
Server-side error |
OutOfResources |
Resource limit reached |
Blob |
Binary data received |
Stdout |
Streaming stdout output |
Stderr |
Streaming stderr output |
ParsedPrivateKey
Supports RSA (≥2048 bits), ED25519, and ECDSA (P-256, P-384) keys.
# From file
key = ParsedPrivateKey.from_file("~/.ssh/id_ed25519")
# From string
key = ParsedPrivateKey.parse(key_content)
Example
See main.py for a complete usage example.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pie_client-0.2.1.tar.gz
(20.4 kB
view details)
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 pie_client-0.2.1.tar.gz.
File metadata
- Download URL: pie_client-0.2.1.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81ce1372cc91b668217ba5d1a0a61ff2f502173b6906de3949451fb23abc15b
|
|
| MD5 |
cdb11740e78eb55e54fe2d4b72440ca9
|
|
| BLAKE2b-256 |
ffff1eb46827308bde9d3438d80c11af55c1fed93e3dd90f0aaca79fdf58466a
|
File details
Details for the file pie_client-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pie_client-0.2.1-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21c792fcec9825ecc1f97118f402a6651f1c296a41e16f123416ad4876825e8c
|
|
| MD5 |
d991e83cdd51f51c744ef24c2ef277cc
|
|
| BLAKE2b-256 |
ab10ce8041e1e74fd44840c222d2e6058e7f16ac816a5992bdcc434f92393009
|