> ## Documentation Index
> Fetch the complete documentation index at: https://wiki.latch.bio/llms.txt
> Use this file to discover all available pages before exploring further.

# Parameter Encoding

## 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 `int`s, `float`s, and `str`s are encoded normally, as shown below.

```json theme={null}
{
  "str_param": "this is a string parameter",
  "int_param": 12,
  "float_param": 3.45
}
```

## Collection Types

Collection types like `list`s and `dict`s are also encoded normally, e.g.

```json theme={null}
{
  "list_of_str_param": ["a", "b"],
  "dict_str_int_param": {
    "c": 1,
    "d": 2
  }
}
```

## Dataclasses

Dataclasses are encoded the same as `dict`s, where field names become keys and field values become values. For example, the following dataclass definition and value

```python theme={null}
@dataclass
class A:
    f1: int
    f2: str

dataclass_param = A(1, "two")
```

would be encoded as

```json theme={null}
{
  "dataclass_param": {
    "f1": 1,
    "f2": "two"
  }
}
```

## LatchFile and LatchDir

`LatchFile`s and `LatchDir`s are encoded as specially formatted `/ldata` strings. For example

```json theme={null}
{
  "file_param": "/ldata/123.account/hello.txt",
  "dir_param": "/ldata/123.account/fastq_dir"
}
```

See [storage](./storage) for more details.

## Enums

Lastly, Enum parameters are encoded as their value. For instance, the following definition and values

```python theme={null}
class Test(Enum):
    a = 1
    b = "two"

param_a = Test.a
param_b = Test.b
```

would be encoded as

```json theme={null}
{
  "param_a": 1,
  "param_b": "two"
}
```
