ComfyLAB — Visual Lab Automation Environment
🌐 Official Website & Interactive Showcase: https://gateeit-ifgw.github.io/ComfyLAB/
ComfyLAB (Comfortable Lab Automation Blocks) is a visual, block-based software platform for automating scientific and test & measurement laboratory experiments. It allows researchers, students, and engineers to connect instruments, run analysis code, and view live plots using an intuitive drag-and-drop workspace.
Developed and maintained by the Electronics and Instrumentation team from the "Gleb Wataghin" Physics Institute (IFGW) at the University of Campinas (UNICAMP).
✨ Features
- Visual Block Programming: Design automation procedures by connecting blocks together. No complex programming required.
- Rich Block Library: Extensive set of built-in blocks covering math, curve fitting, signal processing, array manipulation, control flow, file I/O, live plotting, instrument drivers, and utility functions.
- Run Scripts in 13+ Languages & Native DLLs: Run code blocks written in Python, Rust, C#, Julia, R, JavaScript, TypeScript, Lua, Octave, Maxima, Sage, Wolfram, or PowerShell, and bridge compiled C/C++ DLLs/.so or Windows ActiveX/COM controllers directly in your pipeline.
- Equipment Control: Connect and control physical laboratory hardware via VISA/SCPI protocol and dedicated instrument drivers.
- Built-in Laboratory Safety: If an automation run fails, is stopped, or encounters an error, ComfyLAB automatically triggers safety shutdown routines on instruments (e.g. turning off lasers or signal generator outputs) to protect your hardware.
- Real-Time Live & Multi-Trace Graphs: Stream data in real time with single and multi-trace live plotting widgets, custom axis limits, and persistent settings.
- Whiteboard Canvas Overlay: Draw diagrams, write notes, and add shapes directly on top of your workspace.
- Custom Cluster Blocks: Group a set of connected blocks into a single custom cluster block to keep your workspace clean and organized.
- Security Protections: Prevents untrusted blueprints from executing malicious scripts on your computer. You will be warned and asked for approval before running code from unknown sources.
- Secure Remote Access: Remotely access your lab setup PC running ComfyLAB, protected by a simple two-word token (user/password also available if needed).
- ComfyLAB Official Store & Modular Ecosystem: Decoupled instrument driver, cluster, and blueprint store. Install support for specific laboratory hardware with 1 click, subscribe to makers (Keysight, Tektronix, Thorlabs, etc.) with automated sync, and let dependencies auto-resolve.
- Application Info & About Modal: Access application details, license info, and versioning directly from the UI toolbar.
🚀 Getting Started
You can install and run ComfyLAB in multiple ways:
Option 1: Install from PyPI (Quickest & Recommended)
Install ComfyLAB directly from PyPI via pip:
pip install comfylab
Then start the application from anywhere:
comfylab
(or run via python -m comfylab)
ComfyLAB will launch the backend server and automatically open the application in your default web browser.
Option 2: Pre-compiled Releases (Run-Ready)
A. Standalone Windows Executable (Zero-Dependency)
- Download
comfylab-executable-vX.X.X-windows-x86_64.zipfrom the GitHub Releases page and extract it. - Launch the application:
- Double-click
ComfyLAB.exe.
- Double-click
- Automatically opens in your default browser at
http://localhost:8000(no Python or admin rights required).
B. Base Release Package (Cross-Platform ZIP Archive)
Recommended for Linux and macOS, or Windows users who prefer a lightweight portable folder:
- Download the release
.zippackage (comfylab-release-vX.X.X.zip, ~2 MB) from the GitHub Releases page and extract it. - Launch the application:
- Linux / macOS: Run
bash start.shin a terminal. - Windows: Double-click
start.bat.
- Linux / macOS: Run
- The bootstrapper script automatically initializes a local virtual environment, verifies dependencies, starts the backend, and opens your browser.
Option 3: Running from Source (Developer Mode)
If you cloned the source code from GitHub:
- Ensure you have Python 3.10+ and Node.js (npm) installed.
- Run the bootstrapper:
- Linux / macOS:
bash start.sh - Windows: Run
start.batin Command Prompt.
- Linux / macOS:
- The bootstrapper will:
- Initialize the local
.venvenvironment and install Python requirements. - Run
npm installinsidefrontend/if needed. - Launch the FastAPI backend (port
8000) and the Vite dev server (port5173) concurrently with hot-reloading athttp://localhost:5173.
- Initialize the local
🎛️ Command Line Options
You can customize the startup configuration with command-line flags (supported across comfylab, python -m comfylab, start.sh, and start.bat):
| Argument | Default | Description |
|---|---|---|
--host <ip> |
0.0.0.0 |
Binding address for the server (use 0.0.0.0 for lab network access). |
--port <int> |
8000 |
Port for the FastAPI backend (and web UI in production mode). |
--local |
(disabled) | Restrict server access to localhost only (127.0.0.1). |
--lite |
(disabled) | Launch in Lite Mode (reduces visual effects/animations for lower-power hardware). |
--dev |
(disabled) | Force Development Mode (runs Vite dev server and FastAPI concurrently with hot-reload). |
--vite-port <int> |
5173 |
Port for the Vite dev server (development mode only). |
Examples:
# Run locally with lite visual mode on custom port
comfylab --local --port 8080 --lite
# Run via python module runner
python -m comfylab --host 0.0.0.0 --port 9000
🧩 Block Categories & Capabilities
ComfyLAB provides a rich, modular ecosystem of blocks for building automation workflows:
- Math & Curve Fitting: Basic arithmetic, trigonometric & logarithmic functions, polynomial, exponential, gaussian, and custom non-linear curve fitting.
- Logic & Control Flow: Boolean operations (AND, OR, NOT, XOR), comparisons, execution branches (If/Else), For/While loops, and sequential execution blocks.
- Data Structures & Arrays: Lists, Dictionaries, and multi-dimensional NDArrays (reshaping, slicing, linear algebra, statistics, and array-to-image conversion).
- Signal Processing: FFT & power spectral analysis, bandpass/lowpass/highpass filtering, detrending, windowing, and peak finding algorithms.
- File I/O & Storage: Read and write CSV files, JSON data, Parquet, and raw text files with automatic path resolution.
- Visualization: Interactive single and multi-trace line plots, scatter plots, and heatmaps/image viewers.
- Instruments & VISA: Direct VISA SCPI command/query execution and built-in drivers for oscilloscopes, signal generators, DMMs, optical spectrum analyzers, and power supplies.
- Multi-Language Scripting: Polyglot code execution blocks supporting 13 languages (Python, Rust, C#, JavaScript, TypeScript, Julia, R, Lua, Octave, Maxima, SageMath, Wolfram, PowerShell).
- Clusters: Group complex sub-graphs into custom reusable cluster blocks with dynamic input/output boundaries.
- Utility & Timing: Delays, timestamps, stopwatches, type conversion, console logging, and debugging inspectors.
🛍️ ComfyLAB Store & Modular Equipment Ecosystem
To keep the core distribution ultra-lightweight, portable, and fast to boot, physical vendor hardware drivers, advanced sub-canvas clusters, and complete experiment blueprints are decoupled from the core and distributed modularly through the Official ComfyLAB Store (gateeit-ifgw/comfylab-store).
- Single-Click Installation: Access the Store directly from the top navigation bar (
[ 🛍️ Store ]) or the application menu. Browse by category (Instruments, Clusters, Blueprints, Blocks) or search by vendor and instrument model. - Topological Dependency Resolution: Installing a high-level experiment blueprint or cluster automatically resolves, downloads, and registers all required dependencies (such as underlying instrument drivers and sub-clusters) in the correct topological order.
- Automatic Missing Block Detection: If you open a blueprint referencing hardware drivers or clusters not yet installed locally, ComfyLAB highlights them and provides a one-click button to download the exact required packages from the Store.
- Vendor & Category Subscriptions: Subscribe to All Instruments or individual manufacturers (e.g. Keysight, Tektronix, Agilent, Minipa, Thorlabs, Keithley, CAEN). ComfyLAB checks for new packages and updates on startup or whenever you click "Sync Now".
- Cryptographic Security & Verification: Every store package and the central catalog are digitally signed with Ed25519 cryptography and SHA-256 integrity hashes to ensure all downloaded drivers are authentic and untampered.
📸 Example Workflows
| Experiment Automation Pipeline | Interactive Data Analysis & Plotting |
|---|---|
🏗️ Technical Architecture
The execution engine uses a Hybrid State Machine (Push/Pull) model inspired by game engine blueprints (such as Unreal Engine Blueprints), allowing cycles/loops and branches while retaining lazy evaluation of math/logic pipelines.
graph TD
subgraph Execution Wires [Push Token Flow]
Start[Entry Block] -->|Exec Token| BlockA[Execution Block]
BlockA -->|Exec Token| BlockB[Execution Block / Loops]
end
subgraph Data Wires [Pull Lazy Evaluation]
BlockA -->|Pulls Data| MathAdd[Math Block]
MathAdd -->|Pulls Data| ConstNum[Number Block]
end
1. Push Wires (Execution Token)
- Defined by connections of type
execbetweenExecOutandExecInpins. - Wires push an "Execution Token" forward, specifying state changes and the sequential execution order.
- Execution path loops (cycles) are natively supported for operations like
ForLoop.
2. Pull Wires (Lazy Evaluation Data Bus)
- Defined by connections of type
databetweenDataOutandDataInpins. - Calculated on demand (lazy evaluation) when an execution block pulls data.
- Calculation results are cached within a single execution step to prevent redundant recalculation. Caching is cleared between execution steps.
3. VISA Concurrency (ResourceLockManager)
- Automating hardware requires calling blocking VISA APIs.
- To prevent conflicts when multiple blocks access the same physical hardware concurrently, the
ResourceLockManagermanages async locks mappingVISA address -> asyncio.Lock. - Safely resolves resource contentions with timeout/watchdog support to prevent deadlocks.
📂 Project Structure
ComfyLAB/ (root)
├── pyproject.toml # Modern PEP 517/518 packaging configuration (PyPI)
├── MANIFEST.in # Source distribution inclusion/exclusion rules
├── LICENSE # Software license (GPLv3)
├── README.md # This document
├── requirements.txt # Python package dependencies
├── VERSION # Application version tracking
├── start.sh # Linux/macOS venv bootstrapper
├── start.bat # Windows venv bootstrapper
├── start.py # Cross-platform startup launcher (delegates to comfylab.cli)
├── pyinstaller_entry.py # PyInstaller application entry point
├── build_exe.py # Builds the standalone single-file executable
├── build_release.py # Builds the release ZIP and PyPI wheel packages
├── ComfyLAB.spec # PyInstaller spec (frozen core + external blocks)
├── backend/ # FastAPI API routers & WebSockets server
│ └── routers/store.py # Store API, package download, dependency resolution & subscriptions
├── comfylab/ # Core Python Package & Execution Engine
│ ├── __main__.py # Entry point for `python -m comfylab`
│ ├── cli.py # Unified CLI coordinator & argument handler
│ ├── engine/ # Models, executor, lock manager, registry, security, config
│ ├── blocks/ # Block protocol (base), category modules, scripts, VISA, Store loader
│ ├── clusters/ # Built-in generic & virtual cluster definitions
│ ├── devices/ # Extensible base & virtual instrument driver modules
│ └── examples/ # Built-in generic example experiment workflows (.json)
├── frontend/ # React + Vite + React Flow web UI (includes Store modal)
├── dist/comfylab-store/ # Official Store repository (packages, catalog, CI actions)
└── tests/ # Automated pytest integration & unit tests
📦 Building Releases (For Developers)
ComfyLAB provides automated build scripts in the root directory to generate production distribution packages.
1. Build Portable ZIP Release Package
To compile the frontend and package a ready-to-run release .zip:
python3 build_release.py
# Optionally bump version before building:
python3 build_release.py --bump [patch|minor|major]
2. Build Standalone Windows Executable
To compile the standalone Windows executable (ComfyLAB.exe) from Linux/macOS using Docker and Wine:
./build_windows_docker.sh
Or directly on a native Windows machine:
python build_exe.py
🧪 Running the Verification Suite
To execute all unit and integration tests:
python3 -m pytest tests/
🏛️ Development & Maintenance
ComfyLAB is developed and maintained by the Electronics and Instrumentation team from the "Gleb Wataghin" Physics Institute (IFGW) at the University of Campinas (UNICAMP), Brazil.
📄 License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
🤖 AI Assistance Disclosure
Portions of this codebase were developed with the assistance of AI coding tools. All design decisions, architecture, domain-specific logic, and final implementation choices were authored and reviewed by the project maintainer. AI tools were used as a productivity aid, in the same spirit as an IDE, a linter, or a documentation reference.
Metadata
Release files for comfylab 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| comfylab-0.7.0.tar.gz | 2.1 MB | Without provenance | Details for comfylab-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| comfylab-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for comfylab-0.7.0-py3-none-any.whl |
Total release size: 4.2 MB
Release files / comfylab-0.7.0.tar.gz
| Download URL | comfylab-0.7.0.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e46f84eeea2aebe9cfbf355a292273251e345a0ddc53233f893cce6e56196c0
|
|
BLAKE2b-256 checksum How to use checksums |
3b0f88f525eb8df28e2fcf1f135f99ff98c2a901f7ee70690710efe8be1c9141
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / comfylab-0.7.0-py3-none-any.whl
| Download URL | comfylab-0.7.0-py3-none-any.whl |
|---|---|
| Size | 2.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d13fcb57ec9328890dae96bc85799ebc2d7288aa1432ffc2b08555bb306b284
|
|
BLAKE2b-256 checksum How to use checksums |
e74e6349d6bb17b5cf048e739566ad6ad954b118c593c80987f299a8b39e4edf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for comfylab 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.