Skip to main content

Generic server-authoritative sync library for ASGI apps (Starlette, FastAPI)

Project description

lab-link Python

Starlette/Pydantic backend runtime and Python sync client for lab-link.

Bind a reactive state model, expose a WebSocket sync endpoint, run commands with hardware side effects, broadcast versioned JSON Patch updates, or control a lab-link server from Python.

uv add lab-link
from lab_link import LabSync, ReactiveModel

class AppState(ReactiveModel):
    voltage: float = 0.0

sync = LabSync()
state = sync.bind_state(AppState())

@sync.command
def set_voltage(value: float):
    state.voltage = round(value, 3)  # validated, batched, broadcast

app = sync.create_app()
from lab_link import LabLinkClient

with LabLinkClient("ws://127.0.0.1:8000/sync/ws") as sync:
    snapshot = sync.snapshot()
    ack = sync.send_command("set_voltage", {"value": 1.2})

Full docs: https://sansseriff.github.io/lab-link/

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

lab_link-0.3.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lab_link-0.3.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page