Automate your workflows
A workflow is a lab protocol written in Python. The platform runs it, records every run with its inputs, logs and results, and lets your team start it from the web interface. You build it from three layers: a workflow for the whole procedure, phases for its stages, and steps for single actions. Each layer is a decorated async function.
You need uv and access to the UniteLabs package registry (see Set up your development machine). Then create a project:
uv init first-workflow && cd first-workflow
uv add "unitelabs-sdk[automate]"
import asyncio
from unitelabs.sdk import get_logger, phase, step, workflow
# STEP: one action that completes or fails as a whole. In a real
# workflow this calls a device, like the scripts in the previous pages.
@step(name="Measure")
async def measure(sample: str) -> float:
readings = {"S1": 450.0, "S2": 210.0, "S3": 890.0} # stand-in data
return readings[sample]
# PHASE: a group of steps that ends in a stable state
@phase(name="Check samples")
async def check_samples(samples: list[str], threshold: float) -> list[str]:
passed = []
for sample in samples:
if await measure(sample) >= threshold:
passed.append(sample)
return passed
# WORKFLOW: the whole procedure. Its arguments become the inputs
# you fill in when you start a run on the platform.
@workflow(name="Sample check")
async def sample_check(threshold: float = 300.0) -> list[str]:
passed = await check_samples(["S1", "S2", "S3"], threshold)
get_logger().info(f"Passed: {passed}")
return passed
if __name__ == "__main__":
asyncio.run(sample_check())
Run it with uv run sample_check.py. No credentials and no hardware are needed. The log shows the workflow, the phase and each step finish one by one, and ends with Passed: ['S1', 'S3']. The workflow engine tracks every layer, which is what lets the platform retry a failed step, resume a run from its last finished phase, and show the run step by step.
Run it on the platform
The file runs on the platform without changes. To deploy it, put it in a copy of the workflow template: a repository with one folder per workflow and a deploy script. Deploy a workflow walks through it, and the workflow then appears in your tenant with threshold as a form field.
Next steps
- Workflow: how workflows, phases and steps fit together, and how a run carries its state.
- Workflow template: reference workflows for liquid handling and human-in-the-loop that run in simulation.
- Deploy a workflow: bundle a workflow and ship it to your tenant.
Last updated
Liquid handling as code
One simulator script that defines labware, places it on a Hamilton STAR deck, transfers 100 µL into a plate column and leaves the robot in a safe state.
Self-Paced Setup Guide
Work through getting set up, connecting your instruments, and building your first workflow at your own pace, with a progress checklist that saves as you go.