Skip to main content
Available in latch >= 2.62.0
The Latch SDK provides a Python API to programmatically launch workflows and monitor their status. This is useful for integrating workflows into automated test suites (e.g., GitHub CI/CD). There are two ways to launch a workflow programmatically:
  1. Call the workflow with Python parameter values.
  2. Use a LaunchPlan from a previously registered workflow.

Pre-requisites

  • Please make sure you have registered your workflow to Latch using latch register. This creates a new workflow version, which you will reference in your script.

Usage

  • Using Python parameter values
  • Using a previously registered LaunchPlan
from latch.types.file import LatchFile
from latch_cli.services.launch.launch_v2 import launch
from wf.entrypoint import GenomeReference, Sample

# Using python parameter values
execution_id = launch(
    wf_name="my_workflow",
    version="0.1.0",
    params={
        "input": [
            Sample(
                patient="TestSample",
                fastq_1=LatchFile(
                    "latch:///test_L1_1.fastq.gz"
                ),
                ...
            ),
            ...
        ],
        "genome": GenomeReference.GATK_GRCh37,
        ...
    }
)
Parameters:
  • wf_name: Name of the workflow function. This is the function defined immediately after the @workflow decorator in your code (Example)
  • version: Workflow version registered on Latch
  • params: Dictionary of parameter names and values. If the python values are not typed using the exact same types used in the workflow function signature (including the module paths), the best_effort parameter should be set to True.
  • best_effort (default True): (available in latch >= 2.67.8) When set to True, allows for flexible conversion of params to workflow inputs. This enables launching workflows outside of the workflow environment with compatible values (e.g., strings for enums where the string matches an enum option, or dictionaries/dataclasses with all the fields of a particular dataclass).
Important note on Python version: If the Python version in the workflow’s Docker image does not match the Python version running the script that calls launch or launch_from_launch_plan, the function may fail with a dill unpickling error. In this case, it is recommended to use the same Python version used during workflow registration.
I