Skip to main content

A Python framework for instrument control and experiment automation.

Project description

LabDaemon Mascot

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 docs

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labdaemon-1.0.1.tar.gz (480.6 kB view details)

Uploaded Source

Built Distribution

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

labdaemon-1.0.1-py3-none-any.whl (77.6 kB view details)

Uploaded Python 3

File details

Details for the file labdaemon-1.0.1.tar.gz.

File metadata

  • Download URL: labdaemon-1.0.1.tar.gz
  • Upload date:
  • Size: 480.6 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

Hashes for labdaemon-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c35f9fe867fa9d793c396a5a150062eb8c3b503c1a35f007dd08f0ebc1a10493
MD5 0273cd3f83b968705f8b4616bf45843a
BLAKE2b-256 0d22c2c5899bdf84fac936a55fcd65097843e009cd6f9998759c31bd9cbad3ca

See more details on using hashes here.

File details

Details for the file labdaemon-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: labdaemon-1.0.1-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

Hashes for labdaemon-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a263a42f52718c76b256d0bbbd70bdd7a0d72c5309279fb23b855508eb23a6a5
MD5 539c26af81c476ca3c03cc8fe9df9513
BLAKE2b-256 27311b3396c0784c6001fd7d44d5291cd95cc961b9d4915431193d42b8735125

See more details on using hashes here.

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