Skip to main content

/ Python SDK



license

Connect a Python project to a Dashwire control plane.

Register capabilities, synchronize state, receive commands, and publish logs from Python.

Installation · Usage · Capabilities · Repository


Overview

dashwire is the Python counterpart of @dashwire/sdk. It builds the same dashboard structure from the capabilities you register, registers the project over HTTP (POST /api/projects/:id/register), and keeps a realtime Socket.IO connection to the server's /sdk namespace for state updates, commands, actions, and logs.

The connection runs on background threads, so it works in plain scripts, workers, and web apps alike. Handlers are called from the socket thread.

Installation

Requires Python 3.9 or newer.

pip install "git+https://github.com/meesakveld/dashwire.git#subdirectory=packages/python-sdk"

From a local checkout:

pip install -e packages/python-sdk

Usage

import os
from dashwire import Dashboard

dashboard = Dashboard(
    id="warehouse-worker",
    name="Warehouse Worker",
    server_url=os.environ.get("DASHWIRE_SERVER_URL"),
    token=os.environ.get("DASHWIRE_TOKEN"),
)

with dashboard.section("Runtime") as section:
    section.status("health", label="Health", value="Operational", tone="success")

    maintenance = section.toggle("maintenance", label="Maintenance mode", value=False)

    @maintenance.on_change
    def on_maintenance(enabled: bool) -> None:
        print("Maintenance mode:", enabled)

    terminal = section.terminal("logs", label="Logs")

dashboard.connect()
terminal.log.info("Service started")
dashboard.wait()  # or dashboard.run_forever() instead of connect() + wait()

connect() blocks until the project is registered, retrying with exponential backoff (max. 30s) while the server is unreachable. Once connected, the Socket.IO client reconnects automatically and re-sends the current state after every reconnect.

Dashboard can also be used as a context manager: with Dashboard(...) as dashboard: connects on enter and disconnects on exit.

A complete example lives in examples/basic.py.

Capabilities

Register capabilities inside a section with with dashboard.section(name) as section:. All options are keyword arguments.

Method Purpose Handler
toggle(key, label, value) Boolean control on_change(value: bool)
color(key, label, value) Color value control on_change(value: str)
number(key, label, value, min, max, step, unit, writable) Numeric value; writable when a handler is given on_change(value)
slider(key, label, value, min, max, step) Bounded numeric slider on_change(value)
select(key, label, value, options) Select control; options are {"label", "value"} dicts or plain strings on_change(value: str)
action(key, label, confirm) Trigger an operation on_execute()
status(key, label, value, tone) Read-only status value —
terminal(key, label, writable) Log output and optional commands on_command(command: str)

Every method returns a handle:

  • handle.value – current value
  • handle.set_value(value) – update locally and push to the dashboard
  • @handle.on_change – register a handler as a decorator (alternative to the keyword argument)
  • terminal.log.debug/info/warn/error(message, metadata=None) – publish a log line

Other Dashboard methods: get_structure(), subscribe(listener), emit_log(level, message, source, metadata), is_connected(), disconnect().

Configuration

Argument Environment fallback Default
server_url DASHWIRE_SERVER_URL http://localhost:4000
token DASHWIRE_TOKEN, DASHWIRE_SERVER_TOKEN, SERVER_JWT none

Tokens are created on the server's /security page. Do not commit production tokens to source control.

Log output uses the standard logging module under the dashwire logger.

Development

cd packages/python-sdk
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

Repository

This package is maintained in the Dashwire monorepo.

License

Licensed under the ISC License.

Metadata

Release files for dashwire 0.1.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 dashwire 0.1.0
File Size Uploaded
dashwire-0.1.0.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dashwire 0.1.0
File Interpreter ABI Platform
dashwire-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.4 kB

Release files / dashwire-0.1.0.tar.gz

Download URL dashwire-0.1.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
04944c1a2d25a2e746e13d71a3a0352456035608d5ce7c05afd19a408cd2fd8a
BLAKE2b-256 checksum
How to use checksums
390377bef9322348704e90727962152f86dfaf76f2900d05e41aa1653dd8a9a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / dashwire-0.1.0-py3-none-any.whl

Download URL dashwire-0.1.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c95de76101f6435cf6f12d85b63452fa3e29ed7b168d5078f5bbda4ebca5f2b
BLAKE2b-256 checksum
How to use checksums
3ac3af23f560c4b2dfede3d57feb976f66a871db1a900e4f9220c29d073d11be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

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