|
| 1 | +# How to use looper with bulker |
| 2 | + |
| 3 | +[Bulker](https://bulker.io) is a multi-container environment manager that provides containerized CLI tools via lightweight shim scripts. Looper ships with built-in compute packages for running bulker-activated pipelines, both locally and on SLURM clusters. |
| 4 | + |
| 5 | +!!! note "What you'll accomplish" |
| 6 | + Run a bulker-activated pipeline locally or on a SLURM cluster using looper's built-in bulker compute packages. |
| 7 | + |
| 8 | +!!! info "Prerequisites" |
| 9 | + - Looper is installed and working |
| 10 | + - Bulker is installed and you have a crate manifest for your pipeline |
| 11 | + |
| 12 | +## 1. Specify the bulker crate in your pipeline interface |
| 13 | + |
| 14 | +The pipeline author specifies which bulker crate to use in the `compute` section of the pipeline interface: |
| 15 | + |
| 16 | +```yaml title="pipeline_interface.yaml" |
| 17 | +pipeline_name: my_pipeline |
| 18 | +sample_interface: |
| 19 | + command_template: > |
| 20 | + my_tool {sample.input_file} |
| 21 | +compute: |
| 22 | + bulker_crate: bulker/demo:default |
| 23 | +``` |
| 24 | +
|
| 25 | +## 2. Run locally with bulker_local |
| 26 | +
|
| 27 | +To run bulker-activated pipelines on your local machine: |
| 28 | +
|
| 29 | +```shell |
| 30 | +looper run --package bulker_local |
| 31 | +``` |
| 32 | + |
| 33 | +This activates the bulker crate and runs the pipeline command inside the bulker environment. The submission command is `sh`, so jobs run sequentially in the current shell. |
| 34 | + |
| 35 | +## 3. Submit to SLURM with bulker_slurm |
| 36 | + |
| 37 | +To submit bulker-activated pipelines to a SLURM cluster: |
| 38 | + |
| 39 | +```shell |
| 40 | +looper run --package bulker_slurm \ |
| 41 | + --compute partition=standard time='04:00:00' cores='8' mem='16000' |
| 42 | +``` |
| 43 | + |
| 44 | +This uses the built-in `bulker_slurm` template, which handles SLURM submission headers and bulker activation automatically. |
| 45 | + |
| 46 | +## 4. Use pre-commands for environment setup |
| 47 | + |
| 48 | +On many HPC systems, bulker needs additional setup before it can run — for example, loading a module or setting `TMPDIR` to a shared scratch location. Use `pre_command` for this: |
| 49 | + |
| 50 | +```shell |
| 51 | +looper run --package bulker_slurm \ |
| 52 | + --compute partition=standard time='04:00:00' cores='8' mem='16000' \ |
| 53 | + pre_command='export TMPDIR=/scratch/$USER/tmp && mkdir -p $TMPDIR && module load apptainer' |
| 54 | +``` |
| 55 | + |
| 56 | +Or set it in your looper config so you don't have to type it every time: |
| 57 | + |
| 58 | +```yaml title=".looper.yaml" |
| 59 | +pep_config: pep_config.yaml |
| 60 | +output_dir: results |
| 61 | +pipeline_interfaces: |
| 62 | + - pipeline/pipeline_interface.yaml |
| 63 | +cli: |
| 64 | + run: |
| 65 | + package: bulker_slurm |
| 66 | + compute: |
| 67 | + partition: standard |
| 68 | + time: '04:00:00' |
| 69 | + cores: '8' |
| 70 | + mem: '16000' |
| 71 | + pre_command: > |
| 72 | + export TMPDIR=/scratch/$USER/tmp && mkdir -p $TMPDIR && module load apptainer |
| 73 | +``` |
| 74 | +
|
| 75 | +## Available bulker packages |
| 76 | +
|
| 77 | +| Package | Submission | Description | |
| 78 | +|---------|-----------|-------------| |
| 79 | +| `bulker_local` | `sh` | Run bulker-activated pipelines locally | |
| 80 | +| `bulker_slurm` | `sbatch` | Submit bulker-activated pipelines to SLURM | |
| 81 | + |
| 82 | +## Appendix: Built-in bulker templates |
| 83 | + |
| 84 | +### bulker_local template |
| 85 | + |
| 86 | +```bash title="localhost_bulker_template.sub" |
| 87 | +#!/bin/bash |
| 88 | +
|
| 89 | +echo 'Compute node:' `hostname` |
| 90 | +echo 'Start time:' `date +'%Y-%m-%d %T'` |
| 91 | + |
| 92 | +{PRE_COMMAND} |
| 93 | + |
| 94 | +eval "$(bulker activate -e {BULKER_CRATE})" |
| 95 | + |
| 96 | +{ |
| 97 | + {CODE} |
| 98 | +} | tee {LOGFILE} -i |
| 99 | + |
| 100 | +{POST_COMMAND} |
| 101 | +``` |
| 102 | + |
| 103 | +### bulker_slurm template |
| 104 | + |
| 105 | +```bash title="bulker_slurm_template.sub" |
| 106 | +#!/bin/bash |
| 107 | +#SBATCH --job-name='{JOBNAME}' |
| 108 | +#SBATCH --output='{LOGFILE}' |
| 109 | +#SBATCH --mem='{MEM}' |
| 110 | +#SBATCH --cpus-per-task='{CORES}' |
| 111 | +#SBATCH --time='{TIME}' |
| 112 | +#SBATCH --partition='{PARTITION}' |
| 113 | +#SBATCH -m block |
| 114 | +#SBATCH --ntasks=1 |
| 115 | + |
| 116 | +echo 'Compute node:' `hostname` |
| 117 | +echo 'Start time:' `date +'%Y-%m-%d %T'` |
| 118 | + |
| 119 | +{PRE_COMMAND} |
| 120 | + |
| 121 | +eval "$(bulker activate -e {BULKER_CRATE})" |
| 122 | + |
| 123 | +{CODE} |
| 124 | + |
| 125 | +{POST_COMMAND} |
| 126 | +``` |
| 127 | + |
| 128 | +## See also |
| 129 | + |
| 130 | +- [Configuring cluster computing](../user-tutorial/compute-settings.md) -- tutorial on compute settings |
| 131 | +- [Custom submission templates](custom-submission-templates.md) -- create your own compute packages |
| 132 | +- [Running jobs in containers](containers.md) -- Docker and Apptainer packages |
0 commit comments