Skip to main content
This tutorial walks through a practical example of integrating Latch Registry into a workflow.

What You Will Achieve

By the end of this tutorial, your workflow will let scientists seamlessly connect Registry tables to workflow execution. Here’s the user experience you are enabling:
  1. In the UI, scientists click “Import from Registry”, choose a table, and select specific rows.
  2. A modal appears to match Registry column names with the workflow input parameters you define in code.
  3. Once confirmed, the selected rows are imported directly into the workflow.
  4. Users can launch the workflow with the imported data.
  5. The workflow then upserts results back into the same Registry records.
  6. Updated records are visible in the original Registry table, linking inputs with outputs.

Importing rows from Registry

Usage Example

Core Ideas

To import a table from Registry into your workflow, follow these steps:
  1. Define a dataclass: Create a Python dataclass that represents a single row in the samplesheet.
  2. Mark it as a samplesheet: In the LatchMetadata, set samplesheet=True to indicate that this dataclass should be treated as a samplesheet.
  3. Match Registry columns: The fields in your dataclass should match the column names in the Registry table (or be a subset). If your dataclass fields use the exact same names as the Registry columns, the workflow UI will automatically align them in the “column matching” modal.
  4. Wrap rows in SamplesheetItem: Each row should be wrapped in a SamplesheetItem, which allows the workflow to detect whether the row came from Registry.
  5. A SamplesheetItem has two fields:
    • data – the actual row data. For example, row.data.sample_name will give you the value from the sample_name column.
    • record – the Registry Record object for that row.
      • If the row was imported from Registry, record will be populated with the corresponding Record.
      • If the row was created manually (not imported), record will be None.

Upserting rows to Registry

A Table can be modified by using the Table.update() function. Table.update() returns a context manager (and hence must be called using with syntax) with an upsert_record method. Visit the Table Object page for the API reference.

Usage Example

Core Ideas

  • Retrieve the Table ID by calling get_table_id() on the Record object.
  • Initialize a Table object by calling Table(id=table_id).
  • Call Table.update() to get a context manager with an upsert_record method.