The Entrypoint
After writing a metadata file, the last step is to use your metadata file to generate an entrypoint. In the top level of your workflow directory, run the following:
This will create a file in a folder called wf
called entrypoint.py
, containing an autogenerated Latch SDK workflow that subprocesses Snakemake with your parameters injected appropriately.
Note that if you would like to change the interface of your workflow, you need to update the metadata file and then regenerate your entrypoint.
Structure
A Snakemake workflow on Latch consists of two tasks, an initialize()
task and a snakemake_runtime(...)
task.
The initialize
task is responsible for provisioning a network file system that will be shared amongst all snakemake jobs. This filesystem leverages ObjectiveFS to provide performant shared file access backed by Amazon S3.
Once the filesystem is initialized, the snakemake_runtime
task is scheduled. The runtime first mounts the shared filesystem during scheduling, then proceeds to execution.
The first step in the snakemake_runtime
task is to format the workflow inputs into a config file that snakemake
can then read. This is done in a straightforward manner by creating a JSON file where top level keys are parameter names, and their values are the parameter values. See encoding for more info on how this encoding takes place. This makes these parameters available to the Snakemake workflow through the config
dictionary.
After this, the next step is to call snakemake
directly through subprocess
. The config file generated previously is passed as an argument to the command, along with --executor latch
and --default-storage-plugin latch
. The former configures snakemake
to use the Latch specific cloud execution plugin to schedule jobs, and the latter configures snakemake
to use the Latch storage plugin to enable the download / upload of files to Latch from snakemake
natively. The mechanisms by which these plugins work are described in detail in the Executor and Storage sections, respectively.
Note that you can modify the entrypoint.py
however you like - this is particularly helpful for e.g. staging inputs
Was this page helpful?