-
Notifications
You must be signed in to change notification settings - Fork 91
WIP: Add guide for running CWL workflows on Puhti #1711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mr-c
wants to merge
13
commits into
CSCfi:master
Choose a base branch
from
mr-c:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
011710f
Create toil-cwl-runner
mr-c 642af2e
add motivation
mr-c e983bc6
pros and cons
mr-c 260c015
Logo
mr-c a2288a0
add toil installation and running instructions
teemukataja 8f33e7f
add python venv
teemukataja eb09d09
add note about SBATCH headers
teemukataja a1d628e
set real partition name as example
teemukataja ff0b5d2
add links
teemukataja 914dc11
Apply suggestions from code review
mr-c a5b169a
Monitoring a running toil-cwl-runner
mr-c c2daeec
python3 to install
mr-c fb99281
Update docs/computing/running/toil-cwl-runner.md
mr-c File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Running CWL workflows on Puhti with `toil-cwl-runner` | ||
|
||
{ width=50% } | ||
|
||
The [Common Workflow Language](https://www.commonwl.org/) is a popular set of open standards implemented by several workflow runners and platforms. | ||
The CWL standards are targeted at creating portable workflows made of command line programs. The steps can be written in any compiled or interpreted language. | ||
Sub-workflows, optional steps, scatter-gather, and implicit parallelism are just some of the features. | ||
|
||
The [Toil workflow system](https://toil.ucsc-cgl.org/) supports running CWL on a variety of schedulers and systems. | ||
|
||
This page describes how run CWL worklflows on Puhti using `toil-cwl-runner`, including the usage of `apptainer` to execute any provided Docker-format containers. | ||
|
||
## Strengths of the Common Workflow Language standards | ||
|
||
- Open standard (free to read, free to contribute to) governed by a [not-for-profit charity which is legally obligated to work in the public interest](https://sfconservancy.org/news/2018/apr/11/cwl-new-member-project/). | ||
- [Multiple implementations](https://www.commonwl.org/implementations/) of the CWL standards | ||
- Used in many [different fields of research](https://www.commonwl.org/gallery/) | ||
- YAML based syntax with [special support in many IDEs](https://www.commonwl.org/tools/#editors) | ||
- Support, but does not require, software containers. Can also work with conda packages, `module load` environments, and locally available software. | ||
- CWL's model works hard to keep site-specific deatuls out of the workflow definition. Enabling portability between laptops, clusters, and cloud systems. | ||
|
||
## Strengths of `toil-cwl-runner` | ||
- Supports sending jobs to Slurm, translating CWL resource requirements to Slurm resources specifications. | ||
- Even when using Slurm, (sub-)tasks do not have to have identical resource requirements. | ||
- Can also run on other batch systems: Grid Engine, Torque, LSF, HTCondor. | ||
- Launches and monitors Slurm jobs for you. Also constructs the `apptainer` commands (or some other software container engine as appropriate: `docker`, `podman`, `singularity`, `udocker`). | ||
- No database needs to be setup. | ||
|
||
## Disadvantages for using `toil-cwl-runner` | ||
- Just a workflow runner. Won't manage your data, or keep track of previous workflow runs. | ||
|
||
## Installing `toil-cwl-runner` | ||
|
||
Install `toil` with `CWL` plugin. | ||
``` | ||
module load python-data | ||
|
||
cd /projappl/<project_nnnnnnn> | ||
python -m venv venv | ||
source venv/bin/activate | ||
|
||
pip install -U setuptools wheel | ||
pip install toil[cwl] | ||
|
||
toil-cwl-runner --version | ||
``` | ||
|
||
Install `nodejs` which provides helpful tools for debugging `toil` internals. | ||
``` | ||
cd /projappl/project_nnnnnnn | ||
wget https://nodejs.org/dist/v18.16.1/node-v18.16.1-linux-x64.tar.xz | ||
tar -xf node-v18.16.1-linux-x64.tar.xz | ||
export PATH=$PATH:/projappl/project_nnnnnnn/node-v18.16.1-linux-x64/bin | ||
``` | ||
|
||
## Defining CWL workflows | ||
|
||
Learning resources | ||
|
||
- [Novice CWL tutorial](https://carpentries-incubator.github.io/cwl-novice-tutorial/), includes detailed setup instructions for local editing and running on Microsoft Windows, macOS, and Linux | ||
- <https://www.commonwl.org/user_guide/> | ||
|
||
## Running CWL workflows with `toil-cwl-runner` | ||
|
||
!!! Note | ||
Singularity containers can't be run in the **login node** or in an **interactive session** due to network constraints. | ||
|
||
When you have defined a workflow with `CWL`, you can send it to the cluster using `sbatch`, and then `toil` will start new jobs for each item in the workflow description. | ||
|
||
### Preliminary Steps | ||
Create working directories for `toil`. | ||
``` | ||
mkdir /projappl/project_nnnnnnn/<job store name> | ||
mkdir /projappl/project_nnnnnnn/<work dir name> | ||
mkdir /projappl/project_nnnnnnn/<tmp name> | ||
``` | ||
|
||
### Creating the sbatch file | ||
The `sbatch` file `workflow.sh` will reference the `CWL` file `workflow.cwl` where you have described your workflow steps. | ||
|
||
!!! Note | ||
See [batch documentation](./creating-job-scripts-puhti.md) on how to fill out the `#SBATCH` values. | ||
|
||
`workflow.sh` | ||
```bash | ||
#!/bin/sh | ||
#SBATCH --job-name=<job name here> | ||
#SBATCH --account=<project_number here> | ||
#SBATCH --time=01:00:00 | ||
#SBATCH --mem-per-cpu=1G | ||
#SBATCH --nodes=1 | ||
#SBATCH --cpus-per-task=2 | ||
#SBATCH --partition=small | ||
|
||
source /projappl/<project_nnnnnnn>/venv/bin/activate | ||
|
||
WORKDIR=/projappl/project_nnnnnnn | ||
SCRATCH=/scratch/project_nnnnnnn | ||
export TMPDIR=$WORKDIR/tmp | ||
export TOIL_SLURM_ARGS="--account=project_nnnnnnn --partition=small" | ||
export CWL_SINGULARITY_CACHE=$WORKDIR/singularity | ||
unset XDG_RUNTIME_DIR | ||
|
||
TOIL_SLURM_ARGS="--account=<project_nnnnnnn> --partition=small" toil-cwl-runner \ | ||
--jobStore $WORKDIR/<job store name> \ | ||
--workDir $SCRATCH/<work dir name> \ | ||
--tmpdir-prefix $TMPDIR/<tmp name> \ | ||
--batchSystem slurm \ | ||
$WORKDIR/workflow.cwl \ | ||
--message "message for job" | ||
``` | ||
|
||
Send your workflow to the cluster. | ||
``` | ||
sbatch workflow.sh | ||
``` | ||
|
||
## Monitoring a running workflow | ||
|
||
Check the output logs from the main Toil job or | ||
run `toil status $WORKDIR/<job store name>`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.