A Python framework for instrument control and experiment automation.
Project description
LabDaemon
Write device drivers and tasks once, run everywhere. Start with simple scripts and painlessly move to GUI and then server. Plain Python device classes, safe concurrency, reusable across scripts, GUIs, and automated experiments. Optional HTTP/SSE server for remote access and multi-client coordination.
Why LabDaemon?
- Write once, run anywhere: Same device code works in scripts, GUIs, and web interfaces
- Thread-safe by default: Automatic per-device locking lets you write simple single-threaded code
- Progressive complexity: Start local, add server when you need remote access
- Plain Python classes: No framework lock-in or inheritance hierarchies
- Real-world tested: Designed for research labs with GPIB, DAQs, lasers, and detectors
Documentation
LabDaemon template - Structuring lab code around this framework
Quick Start
Local Script
import labdaemon as ld
class MyLaser:
def __init__(self, device_id: str, address: str, **kwargs):
self.device_id = device_id
self.address = address
self._instrument = None
def connect(self):
import pyvisa
rm = pyvisa.ResourceManager()
self._instrument = rm.open_resource(self.address)
def disconnect(self):
if self._instrument:
self._instrument.close()
def set_wavelength(self, wl: float):
self._instrument.write(f'WAVELENGTH {wl}')
# Use it
daemon = ld.LabDaemon()
daemon.register_plugins(devices={"MyLaser": MyLaser})
with daemon.device_context("laser1", "MyLaser", address="GPIB0::1") as laser:
laser.set_wavelength(1550.0)
daemon.shutdown()
Add Server for Remote Access
from labdaemon.server import LabDaemonServer
daemon = ld.LabDaemon()
server = LabDaemonServer(daemon, host="0.0.0.0", port=5000)
# Same device code, now accessible via HTTP
daemon.register_plugins(devices={"MyLaser": MyLaser})
laser = daemon.add_device("laser1", "MyLaser", address="GPIB0::1")
daemon.connect_device(laser)
try:
server.start(blocking=False)
print("Server running at http://localhost:5000")
# Control locally OR via HTTP/SSE
laser.set_wavelength(1550.0)
input("Press Enter to stop...")
finally:
server.stop()
daemon.shutdown()
Installation
pip install labdaemon[server]
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 labdaemon-1.0.0.tar.gz.
File metadata
- Download URL: labdaemon-1.0.0.tar.gz
- Upload date:
- Size: 399.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"openSUSE Tumbleweed","version":"20260106","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 |
66e9dcca2bbb115e0fec740ab77566b7a45ea31528dd8c43bccc9b2bb577fc6e
|
|
| MD5 |
466f09ad74deef7d2edc2ded8b2cd628
|
|
| BLAKE2b-256 |
3707ddbda55a47c1fcfd03748882cdaa8dc969198deb4ef58004bdb1ba79b2cb
|
File details
Details for the file labdaemon-1.0.0-py3-none-any.whl.
File metadata
- Download URL: labdaemon-1.0.0-py3-none-any.whl
- Upload date:
- Size: 77.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"openSUSE Tumbleweed","version":"20260106","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 |
6a0dc9eafb46ce060a8f9ab704fbd32fda0c05c06f56fc5038f25bff2bd4d909
|
|
| MD5 |
db8f19ed46c6346bf1c945394ed2b59c
|
|
| BLAKE2b-256 |
cfbdee5f176e19b060d259cde11b0f81cfcd6f98555d337a4a17bf6f376023db
|