From 2334d444b26fb74b5b60b6aeca7433204e36e201 Mon Sep 17 00:00:00 2001 From: Radu Suciu Date: Tue, 11 Nov 2025 08:16:47 -0800 Subject: [PATCH] feat: add rule-specific container configuration option (#30) --- docs/further.md | 18 ++++++++++++++++++ .../__init__.py | 8 +++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/further.md b/docs/further.md index 7501a59..f9d2a9b 100644 --- a/docs/further.md +++ b/docs/further.md @@ -28,6 +28,24 @@ SNAKEMAKE_AWS_BATCH_REGION SNAKEMAKE_AWS_BATCH_JOB_QUEUE SNAKEMAKE_AWS_BATCH_JOB_ROLE +# Rule-Specific Container Images + +By default, all jobs use the global container image specified via `--container-image`. However, you can specify a different container image for individual rules using the `aws_batch_container_image` resource parameter: + +```python +rule my_rule: + input: + "input.txt" + output: + "output.txt" + resources: + aws_batch_container_image="my-custom-image:tag" + shell: + "process_data.sh {input} {output}" +``` + +This allows you to use different containers with specialized tools for different rules within the same workflow, rather than requiring all tools to be present in a single container. + # Example ## Create environment diff --git a/snakemake_executor_plugin_aws_batch/__init__.py b/snakemake_executor_plugin_aws_batch/__init__.py index 783a2ba..eb0cd09 100644 --- a/snakemake_executor_plugin_aws_batch/__init__.py +++ b/snakemake_executor_plugin_aws_batch/__init__.py @@ -132,11 +132,17 @@ def run_job(self, job: JobExecutorInterface): # argument 'external_job_id'. try: + # Use rule-level container image if specified via resources, + # otherwise fall back to global container image + container_image = job.resources.get( + "aws_batch_container_image", self.container_image + ) + job_definition = BatchJobBuilder( logger=self.logger, job=job, envvars=self.envvars(), - container_image=self.container_image, + container_image=container_image, settings=self.settings, job_command=self.format_job_exec(job), batch_client=self.batch_client,