Skip to main content

Overview

On Latch, the workflow interface is defined in the __init__.py file within the latch_metadata folder of your workflow. This file instantiates a SnakemakeV2Metadata object that specifies the interface. When the workflow runs, this metadata is automatically serialized to JSON and passed to your Snakemake pipeline as an external config file. This means any reference to config in your Snakefile is seamlessly populated with values from the interface—no extra setup required. This document explains how parameter values from the interface are encoded into the config file.

Primitive Types

Workflow parameter values are encoded in the following manner. Primitives such as ints, floats, and strs are encoded normally, as shown below.
{
  "str_param": "this is a string parameter",
  "int_param": 12,
  "float_param": 3.45
}

Collection Types

Collection types like lists and dicts are also encoded normally, e.g.
{
  "list_of_str_param": ["a", "b"],
  "dict_str_int_param": {
    "c": 1,
    "d": 2
  }
}

Dataclasses

Dataclasses are encoded the same as dicts, where field names become keys and field values become values. For example, the following dataclass definition and value
@dataclass
class A:
    f1: int
    f2: str

dataclass_param = A(1, "two")
would be encoded as
{
  "dataclass_param": {
    "f1": 1,
    "f2": "two"
  }
}

LatchFile and LatchDir

LatchFiles and LatchDirs are encoded as specially formatted /ldata strings. For example
{
  "file_param": "/ldata/123.account/hello.txt",
  "dir_param": "/ldata/123.account/fastq_dir"
}
See storage for more details.

Enums

Lastly, Enum parameters are encoded as their value. For instance, the following definition and values
class Test(Enum):
    a = 1
    b = "two"

param_a = Test.a
param_b = Test.b
would be encoded as
{
  "param_a": 1,
  "param_b": "two"
}
I