← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / scientific-agent-skills / skills / latchbio-integration / references / nextflow-snakemake.md

Nextflow and Snakemake Integration

Latch supports Python, Nextflow, and Snakemake workflows, but their packaging paths are not interchangeable. Confirm the SDK version and choose one track before generating files.

Nextflow: Documented SDK Wrapper Path

Prerequisites

Install:

uv pip install "latch==2.76.8"

Generate metadata

latch generate-metadata nextflow_schema.json --nextflow

Current generation creates:

latch_metadata/
├── __init__.py
└── generated.py

SDK 2.67.0 changed Nextflow generation to use one generated dataclass containing all parameters and a generated base flow. Older parameters.py examples may no longer match the generated layout.

Register

The currently documented wrapper command is:

latch login
latch register . \
  --nf-script main.nf \
  --nf-execution-profile docker,test

Registration generates a Latch workflow wrapper and latch.config. The exact entrypoint location depends on the generation path and SDK version.

Important:

Generate an entrypoint explicitly

SDK 2.76.8 also exposes:

latch nextflow generate-entrypoint . \
  --nf-script main.nf \
  --execution-profile docker,test \
  --output wf/custom_entrypoint.py

This requires a valid NextflowMetadata object in the metadata root.

Experimental Forch-only registration

The CLI also has:

latch nextflow register . --script-path main.nf

The official CLI guide marks this command experimental and only applicable to Forch, Latch's architecture for running Nextflow in the user's own AWS account. It is not a general alternative to latch register --nf-script. Use it only for a configured Forch/BYOC project with current Latch guidance.

Nextflow configuration rules

Debugging

latch register --staging .
latch develop .
latch nextflow attach --execution-id <execution-id>

Within latch develop, the production storage initializer is unavailable. Follow the official debug-mode guidance: use the local executor, bypass the initializer in debug mode, use a compatible Latch Nextflow base image, and reduce process resources.

Snakemake: Choose a Compatibility Track

The current docs and current stable package expose different Snakemake tracks. Do not mix them.

Track A: legacy flags in 2.76.8 source (documentation conflict)

The 2.76.8 wheel still exposes the snakemake extra, legacy metadata classes, generate-metadata --snakemake, and register --snakefile. However, the official CLI guide marks the Snakemake metadata and registration flags deprecated and says metadata generation no longer works for latch >= 2.55.0.a6.

Treat this as an unresolved source/documentation conflict. The commands below are useful when maintaining a legacy project already known to use this path, but should not be presented as a supported new-project flow without confirming with current Latch documentation or support.

Use Python 3.11 for the broadest compatibility with the pinned Snakemake 7.x dependency:

uv venv --python 3.11
source .venv/bin/activate
uv pip install "latch[snakemake]==2.76.8"

Generate metadata from the workflow config:

latch generate-metadata config.yaml --snakemake

Register:

latch register . --snakefile Snakefile

Relevant options:

latch register . \
  --snakefile Snakefile \
  --metadata-root latch_metadata \
  --cache-tasks

Use the current SnakemakeMetadata, SnakemakeParameter, FileMetadata, EnvironmentConfig, and DockerMetadata APIs from latch.types.metadata. Inspect their signatures before generating hand-written metadata.

Track B: official Snakemake v2 tutorial

The current Snakemake v2 tutorial is a compatibility-specific path. At the time of this refresh, it explicitly requires:

uv venv --python 3.11
source .venv/bin/activate
uv pip install "latch==2.62.1a2"

It uses imports such as:

from latch.types.metadata.snakemake_v2 import SnakemakeV2Metadata

and commands such as:

latch snakemake generate-entrypoint .
latch dockerfile --snakemake -c environment.yaml . -f
latch register -y .

Those v2 metadata modules and the latch snakemake command group are not present in the stable 2.76.8 source tree. The tutorial's generated Dockerfile also pins the workflow runtime separately to latch[snakemake]==2.55.0.a6.

Therefore:

Snakemake resource and environment rules

Generated-File Discipline

Before editing a generated file:

  1. Find the command and source file that generated it.
  2. Determine whether regeneration overwrites the file.
  3. Prefer the documented extension file.
  4. If customization of generated code is unavoidable, record the generation command and stop passing flags that regenerate it.
  5. Diff generated output after every SDK upgrade.

Release Checklist

Official Sources