snakemake-executor-plugin-aws-batch-flex 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,353 @@
1
+ Metadata-Version: 2.5
2
+ Name: snakemake-executor-plugin-aws-batch-flex
3
+ Version: 0.2.2
4
+ Summary: Snakemake executor plugin for AWS Batch that runs each rule in an off-the-shelf container image, such as a biocontainer, with no Snakemake inside
5
+ Project-URL: Homepage, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex
6
+ Project-URL: Repository, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex
7
+ Project-URL: Documentation, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex#getting-started
8
+ Project-URL: Issues, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/issues
9
+ Project-URL: Changelog, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/CHANGELOG.md
10
+ Author: Stephen Smith
11
+ License: MIT
12
+ License-File: LICENSE
13
+ Keywords: aws,aws-batch,bioinformatics,executor,plugin,snakemake
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: boto3>=1.34
22
+ Requires-Dist: pyyaml
23
+ Requires-Dist: snakemake-interface-common<2,>=1.17.4
24
+ Requires-Dist: snakemake-interface-executor-plugins<10,>=9.3.2
25
+ Requires-Dist: snakemake-interface-storage-plugins<5,>=4.0.0
26
+ Provides-Extra: test
27
+ Requires-Dist: pandas; extra == 'test'
28
+ Requires-Dist: pytest; extra == 'test'
29
+ Requires-Dist: pytest-xdist; extra == 'test'
30
+ Requires-Dist: ruff; extra == 'test'
31
+ Requires-Dist: snakemake; extra == 'test'
32
+ Requires-Dist: snakemake-storage-plugin-fs; extra == 'test'
33
+ Requires-Dist: snakemake-storage-plugin-s3; extra == 'test'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # snakemake-executor-plugin-aws-batch-flex
37
+
38
+ Run Snakemake workflows on [AWS Batch](https://aws.amazon.com/batch/) with off-the-shelf
39
+ container images. Each rule runs in the image its `container:` directive names, exactly as
40
+ published: a biocontainer from quay.io, a stock image from Docker Hub, your own ECR image. You
41
+ don't build images with Snakemake in them, and the images don't need Python either.
42
+
43
+ **How it works.** On EC2, a Snakemake environment is baked into the machine image (AMI) that
44
+ Batch starts instances from, and mounted read-only into every job's container; this is how
45
+ Nextflow brings its AWS CLI to jobs. On Fargate, which has no instances to customise, Snakemake
46
+ is installed into the container when the job starts. Inputs and outputs go through S3 with
47
+ Snakemake's S3 storage plugin. Instances start when jobs arrive and stop when the queue is
48
+ empty, so you pay only while jobs run.
49
+
50
+ **Which AWS Batch plugin?** The Snakemake organisation maintains
51
+ [snakemake-executor-plugin-aws-batch](https://github.com/snakemake/snakemake-executor-plugin-aws-batch),
52
+ which runs `snakemake` inside each job's container. Its jobs use an image that has Snakemake and
53
+ the S3 storage plugin, either its published image or ones you build on top of it, and a rule
54
+ can name its own image through a resource. That suits workflows whose tools fit in one image or
55
+ a few custom ones. This plugin brings Snakemake to the job instead, so each rule runs in its own
56
+ `container:` image unchanged, such as a biocontainer, and conda envs work in images without
57
+ conda. In return, it needs its own AMI on EC2, or installs Snakemake when each job starts. (As
58
+ of October 2026; see each plugin's docs for the current details.)
59
+
60
+ This plugin also:
61
+
62
+ - sets up the AWS side (AMI, queue, roles, bucket, profile) with one command;
63
+ - mixes EC2, Spot and Fargate queues in one run;
64
+ - can run Snakemake itself on AWS (`smkflex run`), so your machine can be switched off;
65
+ - retries jobs that ran out of memory with more memory;
66
+ - reports what each rule used at the end of a run, with `set-resources:` and `set-threads:`
67
+ suggestions to paste into your profile.
68
+
69
+ This page goes from an empty AWS account to a finished test run
70
+ ([Getting started](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex#getting-started)), then covers running your own workflows and the per-rule
71
+ resources. The rest is in three more pages:
72
+
73
+ - [Guide](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md): published pipelines, moving from a cluster, long runs with `smkflex`,
74
+ conda, the usage table, Spot and Fargate, private images, and troubleshooting;
75
+ - [Reference](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md): every profile setting and `smkflex` command, IAM, what has been
76
+ tested, and the limits;
77
+ - [Setup and upkeep](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/setup.md): university and company accounts, updating the machine image,
78
+ setting up by hand, and removing everything.
79
+
80
+ ## Getting started
81
+
82
+ These steps take under an hour. They assume you know Snakemake but not AWS.
83
+
84
+ The plugin needs Snakemake 9.5 or newer and Python 3.11 to 3.13. It has been tested on Linux.
85
+ On Windows, use [WSL](https://learn.microsoft.com/windows/wsl/install) and run everything inside
86
+ it. macOS should work but hasn't been tried.
87
+
88
+ ### 1. What you need
89
+
90
+ - An AWS account. Setting this up costs very little: building the machine image runs one small
91
+ machine for about 10 minutes, and keeping the image costs well under $1 a month. The test run
92
+ in step 5 costs a few cents. If your account comes from your university or company, read
93
+ [University and company accounts](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/setup.md#university-and-company-accounts) first.
94
+ - Somewhere to run commands: a laptop is fine. As with any remote executor, the machine running
95
+ `snakemake` has to stay on and online until the workflow finishes; `smkflex run` runs
96
+ Snakemake on AWS instead (see [Long runs](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#long-runs-smkflex)).
97
+
98
+ ### 2. Install the tools
99
+
100
+ Install [Miniforge](https://github.com/conda-forge/miniforge#install) if you don't already have
101
+ `conda`. Then get this repository and create an environment with everything you need (Python,
102
+ Snakemake, Terraform, the AWS command-line tool and `snakedeploy`):
103
+
104
+ ```bash
105
+ git clone https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex.git
106
+ cd snakemake-executor-plugin-aws-batch-flex
107
+ conda env create -f environment.yml
108
+ conda activate smk-aws
109
+ pip install -e .
110
+ ```
111
+
112
+ Run `conda activate smk-aws` again in every new terminal before the steps below.
113
+
114
+ Check it worked: `snakemake --version` should print a version number (9.x), and
115
+ `snakemake --help | grep aws-batch-flex` should list this plugin's settings.
116
+
117
+ ### 3. Connect to your AWS account
118
+
119
+ The command-line tools need an access key. In the [AWS console](https://console.aws.amazon.com/):
120
+
121
+ 1. Go to **IAM** > **Users** > **Create user**. Give it a name (e.g. `snakemake-admin`).
122
+ 2. On the permissions page choose **Attach policies directly** and tick **AdministratorAccess**.
123
+ (Setup creates machines, roles, a queue and a bucket, which needs broad permissions. Don't
124
+ use your account's root login for this.)
125
+ 3. Open the new user > **Security credentials** > **Create access key** > **Command Line
126
+ Interface (CLI)**. Copy the access key ID and secret access key.
127
+
128
+ Then in your terminal:
129
+
130
+ ```bash
131
+ aws configure
132
+ ```
133
+
134
+ Paste the two keys when asked. For the region, pick the one closest to you, e.g. `eu-west-1`
135
+ (Ireland) or `us-east-1` (N. Virginia), and use the same one everywhere below. Leave the output
136
+ format empty.
137
+
138
+ Check it worked: `aws sts get-caller-identity` should print your account number. (If you log in
139
+ through a university or company page instead, follow
140
+ [University and company accounts](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/setup.md#university-and-company-accounts) for this step.)
141
+
142
+ ### 4. Set up AWS
143
+
144
+ One script does the rest of the setup. It finds your account's default subnets, builds an AMI
145
+ with Snakemake on it (plus conda and pandas, which most published pipelines need), creates the
146
+ queue, compute environment, roles, log group and bucket with Terraform, and installs a global
147
+ Snakemake profile, `~/.config/snakemake/smkflex/config.yaml`, that sets the executor, your queue
148
+ and the S3 storage prefix. `snakemake --profile smkflex` then works in any folder. Use the
149
+ region you picked in step 3:
150
+
151
+ ```bash
152
+ bash scripts/setup.sh --region eu-west-1
153
+ ```
154
+
155
+ It asks twice before creating anything: before building the AMI, which takes 10 to 20 minutes,
156
+ and after showing the Terraform plan (about 20 new resources, nothing changed or removed). At
157
+ the end it checks the whole setup and prints `All good.`. If it stops partway, fix what it
158
+ reports and run the same command again; it continues where it stopped.
159
+
160
+ Options: `--fargate` also creates a Fargate queue and `--spot` a Spot queue (see
161
+ [Spot and Fargate queues](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#spot-and-fargate-queues)), `--extra-package NAME` adds a
162
+ Python package to the AMI, and `--no-conda` leaves conda out. `bash scripts/setup.sh --help`
163
+ lists the rest. To do each step by hand instead, see
164
+ [Setting up by hand](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/setup.md#setting-up-by-hand).
165
+
166
+ Nothing is running, or costing money, yet: instances start when jobs arrive and stop when the
167
+ queue is empty.
168
+
169
+ ### 5. Run the test workflow
170
+
171
+ ```bash
172
+ cd examples/smoke-test
173
+ snakemake --profile smkflex
174
+ ```
175
+
176
+ Snakemake submits two jobs. On the first run Batch has to start an instance, so the jobs wait
177
+ in `RUNNABLE` for a few minutes. Each job then runs in `debian:12`, which has no Python, and
178
+ writes its output to S3. The run ends with `3 of 3 steps (100%) done` and a table of what it
179
+ used.
180
+
181
+ Download the results from the bucket:
182
+
183
+ ```bash
184
+ smkflex pull results --profile smkflex
185
+ cat results/hello.txt results/sum.txt
186
+ ```
187
+
188
+ The first says hello from Debian and `image has NO python3`; the second is `45`. A few minutes
189
+ later the instance shuts down.
190
+
191
+ ### 6. Set a budget alert
192
+
193
+ Before running real pipelines, set a budget alert, so that a mistake (a huge job, a forgotten
194
+ setting) costs an email rather than a surprise bill. In the AWS console, go to **Billing and
195
+ Cost Management** > **Budgets** > **Create budget** > **Use a template** > **Monthly cost
196
+ budget**, and enter an amount (e.g. $50) and your email address. AWS then emails you at 85% and
197
+ 100% of it, and when the month's forecast goes over. It costs nothing.
198
+
199
+ As a rough guide, compute costs about $0.05 per vCPU-hour on on-demand instances (about a third
200
+ of that on Spot), so a job using 4 vCPUs for an hour costs about $0.20. The published RNA-seq
201
+ pipeline in [Running a published pipeline](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#running-a-published-pipeline) ran its
202
+ 53 test jobs for about $0.10; a real run with 20 samples of 30 million reads should cost a few
203
+ dollars (an estimate, not measured). S3 storage is about $0.02 per GB per month. The table at
204
+ the end of every run shows what that run used (see
205
+ [What a run used](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#what-a-run-used)).
206
+
207
+ That completes the setup. Next, depending on what you're running:
208
+
209
+ - a workflow of your own: [Your own workflow](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex#your-own-workflow);
210
+ - a pipeline from the Snakemake workflow catalog: [Running a published pipeline](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#running-a-published-pipeline);
211
+ - a pipeline you've been running on a cluster: read [Your own workflow](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex#your-own-workflow),
212
+ then [Coming from a cluster](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#coming-from-a-cluster).
213
+
214
+ ## Running your workflows
215
+
216
+ ### Your own workflow
217
+
218
+ Each rule runs as one Batch job, in the image its `container:` directive names:
219
+
220
+ ```python
221
+ rule count_lines:
222
+ input: "data/reads.txt"
223
+ output: "results/count.txt"
224
+ container: "docker://debian:12"
225
+ resources: mem_mb=1000
226
+ shell: "wc -l < {input} > {output}"
227
+ ```
228
+
229
+ The workflow runs with S3 as its default storage provider, so jobs read their inputs from the
230
+ bucket, never from your machine, and write their outputs there. In a folder with your
231
+ `Snakefile`:
232
+
233
+ ```bash
234
+ smkflex init # gives this project its own prefix in the bucket
235
+ smkflex push data # uploads data/reads.txt there
236
+ snakemake --profile smkflex # runs the workflow
237
+ smkflex pull results # downloads results/
238
+ ```
239
+
240
+ `smkflex init` writes a project profile, `profiles/default/config.yaml`, whose
241
+ `default-storage-prefix` is the project's own prefix (`s3://YOUR-BUCKET/snakemake/<folder name>`,
242
+ so each project's `results/` stay apart), and adds `data/`, `results/` and the like to the
243
+ folder's `.gitignore`. Snakemake loads that profile automatically on top of `--profile smkflex`,
244
+ so it's the place for this workflow's settings (`default-resources`, `set-resources`,
245
+ `software-deployment-method`, `retries`; see [Tuning jobs](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#tuning-jobs)), while
246
+ the global `smkflex` profile holds what every workflow shares (queue, bucket, roles).
247
+
248
+ Push whatever files and folders your rules and sample sheets name (`smkflex push reads
249
+ samples.tsv`), and pull whichever outputs you want (`smkflex pull results/qc`). Both skip files
250
+ that are already up to date (`--dry-run` lists what would be transferred) and also take absolute
251
+ paths (see [Coming from a cluster](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#coming-from-a-cluster)). Paths that leave the
252
+ project folder (`../raw`) can't be mapped to storage; use an absolute path for those. If
253
+ something you push isn't git-ignored, `push` warns you, since `smkflex run` would otherwise send
254
+ it along with the workflow.
255
+
256
+ `export SNAKEMAKE_PROFILE=smkflex` saves typing `--profile` every time. Everything in the
257
+ [Snakemake docs](https://snakemake.readthedocs.io) applies, with the exceptions listed under
258
+ [Limits](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md#limits). `examples/conformance/` has one small workflow per feature
259
+ (scripts, conda, checkpoints, Fargate, ...).
260
+
261
+ ### Resources per rule
262
+
263
+ Each job's size, queue and other Batch settings come from its rule. This example sets every
264
+ option in the table below; a real rule only needs the few it uses:
265
+
266
+ ```python
267
+ rule align:
268
+ input: "data/{sample}.fq"
269
+ output: "results/{sample}.sam"
270
+ container: "docker://quay.io/biocontainers/bwa:0.7.17--h7132678_9"
271
+ threads: 8
272
+ retries: 4
273
+ resources:
274
+ mem_mb=16000,
275
+ runtime=120, # minutes
276
+ batch_shm_mb=4096, # EC2 only
277
+ disk_mb=100000, # Fargate only
278
+ gpu=1, # needs a queue with GPU instances
279
+ batch_queue="smkflex-big-queue",
280
+ batch_platform="ec2", # only if the queue can't be looked up
281
+ batch_tags="stage=align,project=rnaseq",
282
+ batch_spot_retries=3, # Spot queues
283
+ batch_priority=500, # fair-share queues
284
+ batch_script_python="host", # script: rules only
285
+ # batch_entrypoint='["python3"]', # only if the image's registry can't be read
286
+ # batch_job_definition="my-jobdef", # instead of the plugin's own; it then sets the image
287
+ shell: "bwa mem -t {threads} ref.fa {input} > {output}"
288
+ ```
289
+
290
+ | On the rule | Value | Default | What it does on AWS |
291
+ |---|---|---|---|
292
+ | `container:` | image, e.g. `"docker://quay.io/biocontainers/bwa:0.7.17--h7132678_9"` | *the `default-image` setting* | The image the job runs in. Any registry works (Docker Hub, quay.io, ghcr.io, ECR, ...); `docker://` is optional. Pin a version tag rather than `latest`. Images with an `ENTRYPOINT` work too: Batch can't override it, so the plugin reads it from the registry and builds a command it will run. |
293
+ | `threads:` | whole number of vCPUs | `1` | vCPUs requested. On EC2, a job bigger than the largest instance type the queue allows waits forever (the plugin warns after `runnable-warn-minutes`). On Fargate, vCPUs and memory are rounded up to the nearest size Fargate offers (at most 16 vCPUs and 120 GiB). |
294
+ | `mem_mb` or `mem_mib` (or `mem`) | whole MB or MiB, e.g. `mem_mb=16000`; or `mem="16G"` | *`default-resources`, else 2048 MiB* | Memory requested, a hard limit. 256 MiB is added for the Snakemake process in the job (`mem-overhead-mib`). A job that exceeds it is killed; with `retries` set, it's retried with twice the memory, then four times (`oom-memory-factor`). The end-of-run table shows what each rule really used. |
295
+ | `retries:` (a rule directive) | whole number | *Snakemake's `retries`, else 0* | Snakemake's usual retries (or `retries: 2` in the profile for every rule). A job that ran out of memory gets more on each retry (`oom-memory-factor`), unless the rule scales memory itself with `attempt`, e.g. `mem_mb=lambda wildcards, attempt: 4000 * attempt`; then its own figure is used as is. Jobs that lost their Spot instance are restarted by Batch instead (`batch_spot_retries`) and don't use these up. |
296
+ | `runtime` | minutes, or a string such as `"2h"` or `"90m"` | *no timeout* | Batch stops the job after this long (at least 1 minute). To give every rule a timeout, put `runtime` in `default-resources`. |
297
+ | `batch_shm_mb` | MiB, more than 0 | *Docker's 64 MB* | EC2 only: the size of `/dev/shm`, for tools that use shared memory, e.g. bwa-mem2 or PyTorch data loaders. What's stored there counts towards `mem_mb`. `shared_memory_size_mb` (the aws-batch plugin's name) also works. |
298
+ | `disk_mb` or `disk_mib` (or `disk`) | whole MB or MiB, e.g. `disk_mb=100000`; or `disk="100G"` | *twice the job's input size (Snakemake's default)* | Fargate only: scratch disk for the job, rounded up to 25 GiB steps, at most 200 GiB; jobs get at least 20 GiB (or `ephemeral-storage-gib`). Ignored on EC2, where jobs share their instance's disk (see [Limits](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md#limits)). |
299
+ | `gpu` | whole number of GPUs | *none* | GPUs requested. Needs a queue with GPU instances; not on Fargate. Untested. |
300
+ | `batch_queue` | queue name | *the `queue` setting* | Send this rule to another queue. EC2, Spot and Fargate queues can be mixed in one workflow; the plugin detects which is which. |
301
+ | `batch_platform` | `"ec2"` or `"fargate"` | *detected from the queue* | Force the platform; only needed if the plugin isn't allowed to describe the queue. |
302
+ | `batch_tags` | `"KEY=VALUE,KEY2=VALUE2"` | *none* | Extra tags on this rule's jobs, e.g. for cost reports. They override profile `tags` with the same key. |
303
+ | `batch_spot_retries` | whole number, `0` to `9` | *the `spot-retries` setting (2)* | How many times Batch restarts this rule's job if its Spot instance is reclaimed. `aws_batch_spot_attempts` (retries + 1, `1` to `10`; the aws-batch plugin's name) also works. |
304
+ | `batch_priority` | whole number, `0` to `9999` | *the `scheduling-priority` setting* | Scheduling priority, higher first. Only on queues with a fair-share policy. `aws_batch_scheduling_priority` also works. |
305
+ | `batch_job_definition` | job definition name, `name:revision` or ARN | *the `job-definition` setting* | Use an existing job definition for this rule; it decides the image (see the `job-definition` setting). |
306
+ | `batch_script_python` | `"image"` or `"host"` | *the `script-python` setting (`image`)* | For Python `script:` rules: `"host"` uses Snakemake's own Python instead of the image's. |
307
+ | `batch_entrypoint` | the image's `ENTRYPOINT` as a JSON list, e.g. `'["python3"]'`; `'[]'` for none | *read from the registry* | Only for when the plugin can't read the entrypoint from the registry (it then warns at the start): a private registry without `registry-credentials`, or no network access to it. |
308
+
309
+ To change resources without editing the Snakefile (for a published pipeline, say), use
310
+ `set-resources`, `set-threads` and `default-resources` in the project profile:
311
+
312
+ ```yaml
313
+ default-resources: [mem_mb=4000] # rules that set no memory
314
+ max-threads: 8 # caps rules written for big cluster nodes
315
+ set-resources:
316
+ align:
317
+ batch_queue: smkflex-big-queue
318
+ mem_mb: 32000
319
+ ```
320
+
321
+ These work as usual, and each has a small example in `examples/conformance/`: `shell:`;
322
+ `script:` in Python, R or bash; `run:`; `conda:` and `wrapper:`; `retries` and resources that
323
+ scale with `attempt`; `group:` (a group runs as one Batch job, so its rules must share an
324
+ image); checkpoints, `temp()`, `directory()`, `shadow:`, `log:` and `benchmark:`.
325
+
326
+ ### Most-used settings
327
+
328
+ Plugin settings go in a profile as `aws-batch-flex-NAME: value`, or on the command line as
329
+ `--aws-batch-flex-NAME value`; `setup.sh` writes the usual ones. The ones most often changed:
330
+
331
+ | Setting (`aws-batch-flex-...`) | Value | What it's for |
332
+ |---|---|---|
333
+ | `queue` | queue name | The Batch queue jobs go to. |
334
+ | `default-image` | image | The image for rules without `container:`. |
335
+ | `conda-cache` | `instance` (default), `none` or an `s3://` URL | Reuse built conda envs: shared per instance by default; an S3 URL also keeps a copy in S3 for later runs. |
336
+ | `oom-memory-factor` | number, `1` or more (default `2`) | How much more memory a job gets when it's retried after running out. |
337
+ | `spot-retries` | `0` to `9` (default `2`) | How many times Batch restarts a job whose Spot instance was reclaimed. |
338
+ | `tags` | list of `KEY=VALUE` | Extra tags on every job, e.g. to break costs down by project. |
339
+
340
+ All of them, with their defaults, are in the [Reference](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md#profile-settings).
341
+
342
+ ## AI assistance
343
+
344
+ This plugin was developed with an AI coding assistant (Claude Code, Anthropic), which wrote
345
+ code, tests and documentation under my direction. I designed the approach, reviewed the
346
+ changes, and ran the workflows listed under
347
+ [What's been tested](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md#whats-been-tested) on real AWS Batch. I maintain the
348
+ plugin and am responsible for it; please report problems as
349
+ [issues](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/issues).
350
+
351
+ ## License
352
+
353
+ MIT, see [LICENSE](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/LICENSE).
@@ -23,8 +23,8 @@ snakemake_executor_plugin_aws_batch_flex/sources.py,sha256=N7CEbNjCRu1TXcsDplS_Y
23
23
  snakemake_executor_plugin_aws_batch_flex/tags.py,sha256=kEM53RdqrhQPHrpoaNEric9JOVdyXmR0W0afNWvoULQ,2500
24
24
  snakemake_executor_plugin_aws_batch_flex/transfer.py,sha256=EgEjBTqL1slNuu-w_g4UMPMs4Jii1xsZqHQ_3smE9OA,9294
25
25
  snakemake_executor_plugin_aws_batch_flex/usage.py,sha256=-cbKh-1dlLDqMTm156dfyLWtycyYifdrrKv660v0kiU,12071
26
- snakemake_executor_plugin_aws_batch_flex-0.2.0.dist-info/METADATA,sha256=oJ70a8dKgphvrnOp5in3AUqYXTPvNDycfbCEdbXStoE,21958
27
- snakemake_executor_plugin_aws_batch_flex-0.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
28
- snakemake_executor_plugin_aws_batch_flex-0.2.0.dist-info/entry_points.txt,sha256=mJmQ6XSjNHpTd77Sq1E2NpJ4BveLpqtjdBanp8_Ht3w,167
29
- snakemake_executor_plugin_aws_batch_flex-0.2.0.dist-info/licenses/LICENSE,sha256=Hibr4Ms3FAwzr2RXkjai7WjC4nfp5ZNeu1hJxRaEi4g,1070
30
- snakemake_executor_plugin_aws_batch_flex-0.2.0.dist-info/RECORD,,
26
+ snakemake_executor_plugin_aws_batch_flex-0.2.2.dist-info/METADATA,sha256=kN0DKoxwO6XS0Et2RwTaTZHxSyvrUgtqbPGHTS_MPsY,23084
27
+ snakemake_executor_plugin_aws_batch_flex-0.2.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
28
+ snakemake_executor_plugin_aws_batch_flex-0.2.2.dist-info/entry_points.txt,sha256=mJmQ6XSjNHpTd77Sq1E2NpJ4BveLpqtjdBanp8_Ht3w,167
29
+ snakemake_executor_plugin_aws_batch_flex-0.2.2.dist-info/licenses/LICENSE,sha256=Hibr4Ms3FAwzr2RXkjai7WjC4nfp5ZNeu1hJxRaEi4g,1070
30
+ snakemake_executor_plugin_aws_batch_flex-0.2.2.dist-info/RECORD,,
@@ -1,344 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: snakemake-executor-plugin-aws-batch-flex
3
- Version: 0.2.0
4
- Summary: Snakemake executor plugin for AWS Batch that runs every rule in its own container image
5
- Project-URL: Homepage, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex
6
- Project-URL: Documentation, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex#getting-started
7
- Project-URL: Issues, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/issues
8
- Project-URL: Changelog, https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/CHANGELOG.md
9
- Author: Stephen Smith
10
- License: MIT
11
- License-File: LICENSE
12
- Keywords: aws,aws-batch,bioinformatics,executor,plugin,snakemake
13
- Classifier: Development Status :: 4 - Beta
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: License :: OSI Approved :: MIT License
16
- Classifier: Operating System :: POSIX :: Linux
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
19
- Requires-Python: >=3.11
20
- Requires-Dist: boto3>=1.34
21
- Requires-Dist: pyyaml
22
- Requires-Dist: snakemake-interface-common<2,>=1.17.4
23
- Requires-Dist: snakemake-interface-executor-plugins<10,>=9.3.2
24
- Requires-Dist: snakemake-interface-storage-plugins<5,>=4.0.0
25
- Provides-Extra: test
26
- Requires-Dist: pandas; extra == 'test'
27
- Requires-Dist: pytest; extra == 'test'
28
- Requires-Dist: pytest-xdist; extra == 'test'
29
- Requires-Dist: ruff; extra == 'test'
30
- Requires-Dist: snakemake; extra == 'test'
31
- Requires-Dist: snakemake-storage-plugin-fs; extra == 'test'
32
- Requires-Dist: snakemake-storage-plugin-s3; extra == 'test'
33
- Description-Content-Type: text/markdown
34
-
35
- # snakemake-executor-plugin-aws-batch-flex
36
-
37
- Run [Snakemake](https://snakemake.readthedocs.io) workflows on [AWS Batch](https://aws.amazon.com/batch/),
38
- with each step running in whatever container image you choose: a stock image from Docker Hub,
39
- quay.io/biocontainers, your own ECR repository, and so on. The images don't need Snakemake or
40
- Python inside them.
41
-
42
- In plain terms: you write a workflow on your own computer, and this plugin sends each step to
43
- AWS, where machines are started for you, run the step in its container, save the results to S3
44
- (Amazon's file storage) and shut down again when there's nothing left to do. You pay only while
45
- machines are running.
46
-
47
- How it works, briefly: a copy of Snakemake is built into the machine image (an "AMI") that the
48
- AWS machines start from, and every job gets read access to it. That's why your containers don't
49
- need it. On Fargate (AWS's serverless option, no machines to manage) Snakemake is installed into
50
- the container when the job starts instead.
51
-
52
- **How it differs from the aws-batch plugin.** The other AWS Batch executor in the Snakemake
53
- plugin catalog,
54
- [snakemake-executor-plugin-aws-batch](https://github.com/snakemake/snakemake-executor-plugin-aws-batch), runs
55
- `snakemake` inside each job's container, so every image a rule uses needs Snakemake and the S3
56
- storage plugin installed; the usual biocontainers and stock images can't be used as they are.
57
- This plugin brings Snakemake to the job instead, so each rule can use any image, and conda envs
58
- work in images without conda. It also sets up the AWS side in one command, mixes EC2, Spot and
59
- Fargate queues in one run, can run Snakemake itself on AWS (`smkflex run`), retries jobs that
60
- ran out of memory with more, and reports what each rule used, with the memory and threads to give it.
61
-
62
- This page takes you from nothing to a finished test run ([Getting started](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex#getting-started)),
63
- then shows how to run your own workflow and what you can set on each rule. The rest is in three
64
- more pages:
65
-
66
- - [Guide](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md): published pipelines, moving from a cluster, long runs with `smkflex`,
67
- conda, the usage table, Spot and Fargate, private images, and troubleshooting;
68
- - [Reference](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md): every profile setting and `smkflex` command, IAM, what has been
69
- tested, and the limits;
70
- - [Setup and upkeep](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/setup.md): university and company accounts, updating the machine image,
71
- setting up by hand, and removing everything.
72
-
73
- ## Getting started
74
-
75
- These steps take you from nothing to a finished test run, in under an hour. They assume you're
76
- comfortable typing commands into a terminal, but not that you know AWS or Snakemake.
77
-
78
- It has been tested on Linux. On Windows, use [WSL](https://learn.microsoft.com/windows/wsl/install)
79
- and run everything inside it. macOS should work but hasn't been tried.
80
-
81
- ### 1. What you need
82
-
83
- - An AWS account. Setting this up costs very little: building the machine image runs one small
84
- machine for about 10 minutes, and keeping the image costs well under $1 a month. The test run
85
- in step 5 costs a few cents. If your account comes from your university or company, read
86
- [University and company accounts](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/setup.md#university-and-company-accounts) first.
87
- - Somewhere to run commands: your laptop is fine. When you run `snakemake` it has to stay on
88
- (and online) until the workflow finishes, because it's what tells AWS what to do next;
89
- `smkflex run` hands that to AWS instead (see [Long runs](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#long-runs-smkflex)).
90
-
91
- ### 2. Install the tools
92
-
93
- Install [Miniforge](https://github.com/conda-forge/miniforge#install) if you don't already have
94
- `conda`. Then get this repository and create an environment with everything you need (Python,
95
- Snakemake, Terraform, the AWS command-line tool and `snakedeploy`):
96
-
97
- ```bash
98
- git clone https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex.git
99
- cd snakemake-executor-plugin-aws-batch-flex
100
- conda env create -f environment.yml
101
- conda activate smk-aws
102
- pip install -e .
103
- ```
104
-
105
- Run `conda activate smk-aws` again in every new terminal before the steps below.
106
-
107
- Check it worked: `snakemake --version` should print a version number (9.x), and
108
- `snakemake --help | grep aws-batch-flex` should list this plugin's settings.
109
-
110
- ### 3. Connect to your AWS account
111
-
112
- The command-line tools need an access key. In the [AWS console](https://console.aws.amazon.com/):
113
-
114
- 1. Go to **IAM** > **Users** > **Create user**. Give it a name (e.g. `snakemake-admin`).
115
- 2. On the permissions page choose **Attach policies directly** and tick **AdministratorAccess**.
116
- (Setup creates machines, roles, a queue and a bucket, which needs broad permissions. Don't
117
- use your account's root login for this.)
118
- 3. Open the new user > **Security credentials** > **Create access key** > **Command Line
119
- Interface (CLI)**. Copy the access key ID and secret access key.
120
-
121
- Then in your terminal:
122
-
123
- ```bash
124
- aws configure
125
- ```
126
-
127
- Paste the two keys when asked. For the region, pick the one closest to you, e.g. `eu-west-1`
128
- (Ireland) or `us-east-1` (N. Virginia), and use the same one everywhere below. Leave the output
129
- format empty.
130
-
131
- Check it worked: `aws sts get-caller-identity` should print your account number. (If you log in
132
- through a university or company page instead, follow
133
- [University and company accounts](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/setup.md#university-and-company-accounts) for this step.)
134
-
135
- ### 4. Set up AWS
136
-
137
- One script does the rest of the setup. It finds your account's network, builds a machine image
138
- with Snakemake on it (plus conda and pandas, which most published pipelines need), creates the
139
- queue, roles and bucket with Terraform, and installs a Snakemake profile called `smkflex` in
140
- `~/.config/snakemake/smkflex/`. A profile is a settings file: it tells Snakemake to use this
141
- plugin, your queue and your bucket, and because it's installed by name, `snakemake --profile
142
- smkflex` works in any folder. Use the region you picked in step 3:
143
-
144
- ```bash
145
- bash scripts/setup.sh --region eu-west-1
146
- ```
147
-
148
- It asks twice before creating anything. The first time is before building the machine image,
149
- which takes 10 to 20 minutes. The second is after showing what Terraform will create (about 20
150
- new resources, nothing changed or removed). At the end it checks the whole setup and says
151
- `All good.`. If it stops halfway, fix what it says and run the same command again: it carries on
152
- where it stopped.
153
-
154
- Options: `--fargate` also creates a Fargate queue and `--spot` a cheaper Spot queue (see
155
- [Spot and Fargate queues](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#spot-and-fargate-queues)), `--extra-package NAME` adds a Python
156
- package to the image, and `--no-conda` leaves conda out. `bash scripts/setup.sh --help` lists the
157
- rest. To do each step by hand instead, see [Setting up by hand](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/setup.md#setting-up-by-hand).
158
-
159
- Nothing is running (or costing money) yet: machines start when jobs arrive and stop when the
160
- queue is empty.
161
-
162
- ### 5. Run the test workflow
163
-
164
- ```bash
165
- cd examples/smoke-test
166
- snakemake --profile smkflex
167
- ```
168
-
169
- What happens: Snakemake uploads the workflow to S3 and submits two jobs. The first time, AWS has
170
- to start a machine, so the jobs show as waiting for a few minutes. Then each job runs in its own
171
- container (`debian:12`, which has no Python) and writes its result to S3. When it's finished
172
- you'll see `3 of 3 steps (100%) done`, followed by a table of what the run used.
173
-
174
- Download the results from the bucket and look at them:
175
-
176
- ```bash
177
- smkflex pull results --profile smkflex
178
- cat results/hello.txt results/sum.txt
179
- ```
180
-
181
- The first says hello from Debian and `image has NO python3`; the second is `45`. A few minutes
182
- later the machine shuts itself down.
183
-
184
- ### 6. Set a budget alert
185
-
186
- Before running real pipelines, set a budget alert, so a mistake (a huge job, or a forgotten
187
- setting) costs an email rather than a surprise bill. In the AWS console, **Billing and Cost
188
- Management** > **Budgets** > **Create budget** > **Use a template** > **Monthly cost budget**:
189
- enter an amount (e.g. $50) and your email address. AWS then mails you at 85% and 100% of it, and
190
- when the month's forecast goes over. It takes two minutes and costs nothing.
191
-
192
- As a rough guide: compute costs about $0.05 per vCPU-hour on normal instances (a third of that
193
- on Spot), so a job using 4 vCPUs for an hour costs about $0.20. The published RNA-seq pipeline
194
- in [Running a published pipeline](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#running-a-published-pipeline) ran its 53 test jobs for about
195
- $0.10; a real run with 20 samples of 30 million reads should be a few dollars (an estimate, not
196
- measured). S3 storage is about $0.02 per GB per month. The table at the end of every run shows
197
- what that run used (see [What a run used](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#what-a-run-used)).
198
-
199
- That's the setup done. Next, depending on what you're running:
200
-
201
- - a workflow of your own: [Your own workflow](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex#your-own-workflow);
202
- - a pipeline from the Snakemake workflow catalog: [Running a published pipeline](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#running-a-published-pipeline);
203
- - a pipeline you've been running on a cluster: read [Your own workflow](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex#your-own-workflow),
204
- then [Coming from a cluster](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#coming-from-a-cluster).
205
-
206
- ## Running your workflows
207
-
208
- ### Your own workflow
209
-
210
- A Snakemake workflow is a file called `Snakefile` made of rules. Each rule says what files it
211
- makes (`output`), what it needs (`input`), which container to use, and the command to run:
212
-
213
- ```python
214
- rule count_lines:
215
- input: "data/reads.txt"
216
- output: "results/count.txt"
217
- container: "docker://debian:12"
218
- resources: mem_mb=1000
219
- shell: "wc -l < {input} > {output}"
220
- ```
221
-
222
- Snakemake works out the order from the file names, and with this plugin each rule runs as a
223
- Batch job. The [Snakemake tutorial](https://snakemake.readthedocs.io/en/stable/tutorial/tutorial.html)
224
- explains rules, wildcards and the rest; everything in it works here, with the differences listed
225
- under [Limits](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md#limits).
226
-
227
- Each workflow lives in its own project folder, and its files live in your S3 bucket: jobs read
228
- their inputs from there, never from your computer, so upload them first, and write their outputs
229
- there. Put the `Snakefile` in a new folder and,
230
- in that folder:
231
-
232
- ```bash
233
- smkflex init # gives this project its own folder in the bucket
234
- smkflex push data # uploads data/reads.txt to it
235
- snakemake --profile smkflex # runs the workflow
236
- smkflex pull results # downloads results/ from it
237
- ```
238
-
239
- `smkflex init` writes the project's own settings file, `profiles/default/config.yaml`, with the
240
- project's folder in the bucket (`s3://YOUR-BUCKET/snakemake/<folder name>`, so each project's
241
- `results/` stay apart), and adds `data/`, `results/` and the like to the folder's `.gitignore`.
242
- Snakemake loads that file by itself, on top of the `smkflex` profile, so it's also the place for
243
- anything this workflow needs (memory, conda, retries, see [Tuning jobs](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#tuning-jobs)); the
244
- `smkflex` profile keeps what's the same for every workflow (your queue, bucket and roles).
245
-
246
- `data` is only this example's folder: push whatever files and folders your rules and sample
247
- sheets name (`smkflex push reads samples.tsv`), and pull whichever outputs you want
248
- (`smkflex pull results/qc`). `push` and `pull` skip files that are already there with the same
249
- size (`--dry-run` only lists them) and also take absolute paths (see
250
- [Coming from a cluster](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/guide.md#coming-from-a-cluster)); paths that go up out of the project folder
251
- (`../raw`) can't be mapped to storage, so use an absolute path for those. If something you push
252
- isn't in `.gitignore`, `push` says so, since `smkflex run` would otherwise send it along with
253
- the workflow.
254
- `export SNAKEMAKE_PROFILE=smkflex` saves typing `--profile` every time. `examples/conformance/`
255
- has one small workflow per feature (scripts, conda, checkpoints, Fargate, ...) if you want to
256
- see more.
257
-
258
- ### Resources per rule
259
-
260
- Everything about a job is set on its rule. An example with every option in the table below (a real
261
- rule only needs the few it uses):
262
-
263
- ```python
264
- rule align:
265
- input: "data/{sample}.fq"
266
- output: "results/{sample}.sam"
267
- container: "docker://quay.io/biocontainers/bwa:0.7.17--h7132678_9"
268
- threads: 8
269
- retries: 4
270
- resources:
271
- mem_mb=16000,
272
- runtime=120, # minutes
273
- batch_shm_mb=4096, # EC2 only
274
- disk_mb=100000, # Fargate only
275
- gpu=1, # needs a queue with GPU machines
276
- batch_queue="smkflex-big-queue",
277
- batch_platform="ec2", # only if the queue can't be looked up
278
- batch_tags="stage=align,project=rnaseq",
279
- batch_spot_retries=3, # Spot queues
280
- batch_priority=500, # fair-share queues
281
- batch_script_python="host", # script: rules only
282
- # batch_entrypoint='["python3"]', # only if the image's registry can't be read
283
- # batch_job_definition="my-jobdef", # instead of the plugin's own; it then sets the image
284
- shell: "bwa mem -t {threads} ref.fa {input} > {output}"
285
- ```
286
-
287
- | On the rule | What it does on AWS |
288
- |---|---|
289
- | `container: "docker://..."` | The image the job runs in. Any registry works (Docker Hub, quay.io, ghcr.io, ECR...); `docker://` is optional. Rules without one use `aws-batch-flex-default-image`. Images with an `ENTRYPOINT` work too: Batch can't change it, so the plugin reads it from the registry and gives the jobs a command it runs. |
290
- | `threads: 8` | Number of vCPUs requested. On EC2, a job bigger than the largest machine the queue may start waits forever (the plugin warns after `runnable-warn-minutes`). On Fargate, vCPUs and memory are rounded up to the nearest size Fargate offers (at most 16 vCPUs and 120 GiB). |
291
- | `mem_mb=16000` (or `mem_mib`) | Memory requested, a hard limit. Snakemake itself runs inside the job too, so 256 MiB is added (`mem-overhead-mib`). Without it (many published pipelines don't set it), `default-resources` applies, or else 2048 MiB. A job that goes over it is stopped; with `--retries 2` (or `retries: 2` in the profile) it's retried with twice the memory, then four times (`oom-memory-factor`). The end-of-run table shows what each rule really used. |
292
- | `retries: 2` | Not a resource but a rule setting (or `retries: 2` in the profile for every rule): how many times Snakemake runs a failed job again. A job that ran out of memory gets more on each retry (`oom-memory-factor`), and `attempt` lets a rule raise anything itself, e.g. `mem_mb=lambda wildcards, attempt: 4000 * attempt` (then the rule's own figure is used, not doubled on top). Jobs that lost their Spot machine are restarted by Batch instead (`batch_spot_retries`) and don't use these up. |
293
- | `runtime=120` | Minutes before Batch stops the job (timeout); `"2h"` also works. To give every rule a timeout, put `runtime` in `default-resources`. |
294
- | `batch_shm_mb=4096` | Size of `/dev/shm` (Docker's default is 64 MB), for tools that use shared memory, e.g. bwa-mem2 or PyTorch data loaders. What's stored there counts towards `mem_mb`. EC2 only. `shared_memory_size_mb` also works. |
295
- | `disk_mb=100000` (or `disk_mib`) | Fargate only: disk space for the job, up to 200 GiB, rounded up to 25 GiB steps. Without it, Snakemake asks for twice the size of the job's input files, and jobs get at least 20 GiB (or `ephemeral-storage-gib`). On EC2 it's ignored: jobs share their machine's disk (see [Limits](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md#limits)). |
296
- | `gpu=1` | Number of GPUs (needs a queue with GPU instances; untested). |
297
- | `batch_queue="other-queue"` | Send this rule to a different queue than the profile's. EC2, Spot and Fargate queues can be mixed in one workflow; the plugin works out which is which. |
298
- | `batch_platform="fargate"` | Force the platform instead of detecting it from the queue (only needed if the plugin isn't allowed to look the queue up). |
299
- | `batch_tags="k=v,k2=v2"` | Extra tags on this rule's jobs, e.g. for cost reports. Overrides profile tags with the same key. |
300
- | `batch_spot_retries=0` | How often Batch retries this rule's job if its Spot instance is taken away (0-9; default from the profile, 2). `aws_batch_spot_attempts` (retries + 1) also works. |
301
- | `batch_priority=500` | Scheduling priority, 0-9999, higher first. Only on queues with a fair-share policy. `aws_batch_scheduling_priority` also works. |
302
- | `batch_job_definition="name"` | Use an existing job definition for this rule (see the `job-definition` setting). |
303
- | `batch_script_python="host"` | For Python `script:` rules: use Snakemake's own Python instead of the image's. |
304
- | `batch_entrypoint='["python3"]'` | The image's `ENTRYPOINT`, for when the plugin can't read it from the registry (it then warns at the start): a private registry without `registry-credentials`, or no network to it. `'[]'` for none. |
305
-
306
- To change resources without editing the Snakefile (for a published pipeline, say), use
307
- Snakemake's `set-resources`, `set-threads` and `default-resources` in the project's
308
- `profiles/default/config.yaml`:
309
-
310
- ```yaml
311
- default-resources: [mem_mb=4000] # rules that set no memory
312
- max-threads: 8 # caps rules written for big cluster nodes
313
- set-resources:
314
- align:
315
- batch_queue: smkflex-big-queue
316
- mem_mb: 32000
317
- ```
318
-
319
- Snakemake features that work as usual (each has a small example in `examples/conformance/`):
320
- `shell:` commands; `script:` files in Python, R or bash; `run:` blocks; `conda:` environments and
321
- wrappers (`wrapper:`); `retries: 2`, and resources that grow with each attempt, e.g.
322
- `mem_mb=lambda wildcards, attempt: 4000 * attempt`; `group:` (grouped rules run as one Batch job,
323
- so they must share an image), `checkpoint`, `temp()`, `directory()`, `shadow:`, `log:` and
324
- `benchmark:`.
325
-
326
- ### Most-used settings
327
-
328
- Plugin settings go in a profile as `aws-batch-flex-NAME: value` (or on the command line as
329
- `--aws-batch-flex-NAME value`); `setup.sh` writes the usual ones. The ones people change most:
330
-
331
- | Setting (`aws-batch-flex-...`) | What it's for |
332
- |---|---|
333
- | `queue` | The Batch queue jobs go to. |
334
- | `default-image` | The image for rules that have no `container:`. |
335
- | `conda-cache` | Reuse built conda envs: per machine (default), or kept in S3 for later runs. |
336
- | `oom-memory-factor` | How much more memory a job gets when it's retried after running out (default 2×). |
337
- | `spot-retries` | How many times Batch restarts a job whose Spot machine was taken back. |
338
- | `tags` | Extra tags on every job, e.g. to see costs by project. |
339
-
340
- All of them, with their defaults, are in the [Reference](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/docs/reference.md#profile-settings).
341
-
342
- ## License
343
-
344
- MIT, see [LICENSE](https://github.com/SSmith-NUIG/snakemake-executor-plugin-aws-batch-flex/blob/main/LICENSE).