Skip to main content

Hardware drivers for the PUDA platform.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

puda-drivers

Hardware drivers for the PUDA (Physical Unified Device Architecture) platform. This package provides Python interfaces for controlling laboratory automation equipment.

Features

  • Gantry Control: Control G-code compatible motion systems (e.g., QuBot)
  • Liquid Handling: Interface with Sartorius rLINE® pipettes and dispensers
  • Serial Communication: Robust serial port management with automatic reconnection
  • Logging: Configurable logging with optional file output to logs folder
  • Cross-platform: Works on Linux, macOS, and Windows

Installation

From PyPI

pip install puda-drivers

From Source

git clone https://github.com/zhao-bears/puda-drivers.git
cd puda-drivers
pip install -e .

Quick Start

Logging Configuration

Configure logging for your application with optional file output:

import logging
from puda_drivers.core.logging import setup_logging

# Configure logging with file output enabled
setup_logging(
    enable_file_logging=True,
    log_level=logging.DEBUG,
    logs_folder="logs", # Optional: default to logs
    log_file_name="my_experiment"  # Optional: custom log file name
)

# Or disable file logging (console only)
setup_logging(
    enable_file_logging=False,
    log_level=logging.INFO
)

Logging Options:

  • enable_file_logging: If True, logs are written to files in the logs/ folder. If False, logs only go to console (default: False)
  • log_level: Logging level constant (e.g., logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) (default: logging.DEBUG)
  • logs_folder: Name of the folder to store log files (default: "logs")
  • log_file_name: Custom name for the log file. If None or empty, uses timestamp-based name (e.g., log_20250101_120000.log). If provided without .log extension, it will be added automatically.

When file logging is enabled, logs are saved to timestamped files (unless a custom name is provided) in the logs/ folder. The logs folder is created automatically if it doesn't exist.

First Machine Example

The First machine integrates motion control, deck management, liquid handling, and camera capabilities:

import logging
from puda_drivers.machines import First
from puda_drivers.core.logging import setup_logging

# Configure logging
setup_logging(
    enable_file_logging=False,
    log_level=logging.DEBUG,
)

# Initialize the First machine
machine = First(
    qubot_port="/dev/ttyACM0",
    sartorius_port="/dev/ttyUSB0",
    camera_index=0,
)

# Connect all devices
machine.connect()

# Home the gantry
machine.qubot.home()

# Initialize the pipette
machine.pipette.initialize()

# Load labware onto the deck
machine.load_deck({
    "C1": "trash_bin",
    "C2": "polyelectric_8_wellplate_30000ul",
    "A3": "opentrons_96_tiprack_300ul",
})

# Start video recording
machine.camera.start_video_recording()

# Perform liquid handling operations
machine.attach_tip(slot="A3", well="G8")
machine.aspirate_from(slot="C2", well="A1", amount=100)
machine.dispense_to(slot="C2", well="B4", amount=100)
machine.drop_tip(slot="C1", well="A1")

# Stop video recording
machine.camera.stop_video_recording()

# Disconnect all devices
machine.disconnect()

Discovering Available Methods: To explore what methods are available on any class instance, you can use Python's built-in help() function:

machine = First()
help(machine)  # See methods for the First machine
help(machine.qubot)  # See GCodeController methods
help(machine.pipette)  # See SartoriusController methods
help(machine.camera)  # See CameraController methods

Alternatively, you can read the source code directly in the src/puda_drivers/ directory.

Device Support

The following device types are supported:

  • GCode - G-code compatible motion systems (e.g., QuBot)
  • Sartorius rLINE® - Electronic pipettes and robotic dispensers
  • Camera - Webcams and USB cameras for image and video capture

Logging Best Practices

For production applications, configure logging at the start of your script:

import logging
from puda_drivers.core.logging import setup_logging

# Configure logging first, before initializing devices
setup_logging(
    enable_file_logging=True,
    log_level=logging.INFO,
    log_file_name="experiment"
)

# Now all device operations will be logged
# ... rest of your code

This ensures all device communication, movements, and errors are captured in log files for debugging and audit purposes.

Finding Serial Ports

To discover available serial ports on your system:

from puda_drivers.core import list_serial_ports

# List all available ports
ports = list_serial_ports()
for port, desc, hwid in ports:
    print(f"{port}: {desc} [{hwid}]")

# Filter ports by description
sartorius_ports = list_serial_ports(filter_desc="Sartorius")

Requirements

  • Python >= 3.14
  • pyserial >= 3.5
  • See pyproject.toml for full dependency list

Development

Setup Development Environment

First, install uv if you haven't already. See the uv installation guide for platform-specific instructions.

# Create virtual environment
uv venv

# Activate virtual environment
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
uv sync

# Install package in editable mode
pip install -e .

Building and Publishing

# Build distribution packages
uv build

# Publish to PyPI
uv publish
# Username: __token__
# Password: <your PyPI API token>

Version Management

# Set version explicitly
uv version 0.0.1

# Bump version (e.g., 1.2.3 -> 1.3.0)
uv bump minor

Documentation

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

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

puda_drivers-0.0.10.tar.gz (61.1 kB view details)

Uploaded Source

Built Distribution

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

puda_drivers-0.0.10-py3-none-any.whl (50.3 kB view details)

Uploaded Python 3

File details

Details for the file puda_drivers-0.0.10.tar.gz.

File metadata

  • Download URL: puda_drivers-0.0.10.tar.gz
  • Upload date:
  • Size: 61.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for puda_drivers-0.0.10.tar.gz
Algorithm Hash digest
SHA256 ee35c5b0f9216634a13b623a071db8a5000321c7e048673283d96d8f6de99007
MD5 57ce640ebdb5758fba86b75a2566dd2b
BLAKE2b-256 b14e3352113316b11b0acff32a53591632cdcd283db96673abca4fe381633ef5

See more details on using hashes here.

File details

Details for the file puda_drivers-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: puda_drivers-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 50.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for puda_drivers-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d43a5fb42f2fa2576b87053d85b6d5eee2e7d126e14f0af98db519c75e7edbed
MD5 7434190a3c0450de53ae397a2fd3bb1f
BLAKE2b-256 f4398501e4a0173a00eff64168342c8207b4240eb26380edfbfe18c9b32bab41

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