Skip to content

fix: containerize arguments#58

Merged
m-jahn merged 3 commits intosnakemake:masterfrom
m-jahn:fix_apptainer
Apr 24, 2026
Merged

fix: containerize arguments#58
m-jahn merged 3 commits intosnakemake:masterfrom
m-jahn:fix_apptainer

Conversation

@m-jahn
Copy link
Copy Markdown
Member

@m-jahn m-jahn commented Apr 24, 2026

Summary by CodeRabbit

  • New Features

    • Added support for Apptainer containerization with new options to select output format (Dockerfile or Apptainer definition) and to enable Apptainer installation.
  • Documentation

    • Updated documentation and examples to cover the new containerization options and usage.
  • Chores

    • Updated license attribution to reflect team ownership and extended year range.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

Adds a new containerize-args action input and wiring to pass it to Snakemake's --containerize option; action now conditionally writes either Dockerfile or apptainer.def. Also updates README docs and the LICENSE copyright attribution.

Changes

Cohort / File(s) Summary
License
LICENSE
Replace copyright attribution snakemake (2019) with The Snakemake team and expand year range to 2019-2026.
Action configuration
action.yml
Add containerize-args input (optional string, default empty). Use its value when invoking snakemake --containerize and conditionally choose output filename (apptainer.def vs Dockerfile).
Documentation
README.md
Document new inputs containerize-args and install-apptainer; update task/containerization example to show containerize-args: "apptainer".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action as GitHub Action
    participant Snakemake
    participant FS as Workspace
    User->>Action: provides inputs (task, containerize-args, ...)
    Action->>Snakemake: run `snakemake --containerize <containerize-args>`
    Snakemake->>FS: write container recipe (`Dockerfile` or `apptainer.def`)
    Snakemake-->>Action: exit status / artifacts
    Action->>User: job completes, artifact available
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: containerize arguments' is vague and doesn't clearly describe the main change, which is adding support for the new Apptainer containerization option and conditional output file naming. Consider a more specific title like 'Add Apptainer support to containerize step' or 'Support --containerize apptainer argument' to better convey the primary change.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request successfully implements all coding requirements from issue #57: adds a new 'containerize-args' input, passes it to the --containerize option, and conditionally selects the output filename based on the runtime choice.
Out of Scope Changes check ✅ Passed All changes are directly related to the issue requirements. The LICENSE and README updates appropriately document the new functionality and update copyright; no out-of-scope changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

23-25: ⚠️ Potential issue | 🟡 Minor

Stale task description — now also produces Apptainer recipes.

This section still describes the containerize task as generating "a container image specification (in the form of a Dockerfile)". With the new containerize-args support, the output can also be an Apptainer definition file (apptainer.def). Worth updating so the docs don't contradict the new input documented below.

📝 Suggested wording
 ### `task`

-Whether to run Snakemake or to generate a container image specification (in the form of a Dockerfile) that contains all required environments. Can be either `run` or `containerize`. Default `run`.
+Whether to run Snakemake or to generate a container image specification (a `Dockerfile` or an Apptainer definition file, see `containerize-args`) that contains all required environments. Can be either `run` or `containerize`. Default `run`.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 23 - 25, Update the `task` README description to
reflect that `containerize` can produce either a Dockerfile or an Apptainer
definition file by referencing the new `containerize-args` option; change the
sentence that currently says "a container image specification (in the form of a
Dockerfile)" to mention both "a Dockerfile or an Apptainer definition file (e.g.
apptainer.def)" and keep the allowed values (`run` or `containerize`) and
default (`run`) unchanged so the docs align with `containerize-args` behavior.
🧹 Nitpick comments (3)
README.md (1)

43-45: Align containerize-args doc with the action input description.

Same wording concerns as in action.yml (see my comment there): "Additional arguments for containerize" understates the purpose, and listing '' as a separate option confuses the default behavior. Also, this line is missing a trailing period while the surrounding input descriptions end in one.

📝 Suggested wording
 ### `containerize-args`

-Additional arguments for `containerize`, can be one of 'dockerfile', 'apptainer' or '' (defaults to dockerfile)
+Selects the output format passed to `snakemake --containerize`. One of `dockerfile` or `apptainer`; if unset, Snakemake's default is used (currently `dockerfile`). The generated recipe is written to `Dockerfile` or `apptainer.def`, respectively.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 43 - 45, Update the README entry for the input named
"containerize-args" to match the action input description: clarify that it
selects which containerizer to use for containerize (not "additional
arguments"), list the valid options as "dockerfile" or "apptainer" and state the
default is "dockerfile" (do not list '' as a separate option), and add a
trailing period to the sentence; reference the "containerize-args" input and the
"containerize" action when making the change.
action.yml (2)

124-130: Recipe selection is tied to an exact-literal match — consider normalizing.

The logic is correct for the documented inputs, but the == "apptainer" check is strictly literal. If a user passes "Apptainer", " apptainer", or any future alias that Snakemake may accept, the recipe file will silently be named Dockerfile while Snakemake emits an apptainer definition into it. Not a blocker (Snakemake's error behavior still applies when the value is outright invalid), but a small normalization makes this more robust:

♻️ Optional hardening
       run: |
-        if [[ "${{ inputs.containerize-args }}" == "apptainer" ]]; then
+        containerize_args="$(echo '${{ inputs.containerize-args }}' | tr '[:upper:]' '[:lower:]' | xargs)"
+        if [[ "$containerize_args" == "apptainer" ]]; then
           recipe="apptainer.def"
         else
           recipe="Dockerfile"
         fi
-        snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }} --containerize ${{ inputs.containerize-args }} > $recipe
+        snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }} --containerize $containerize_args > "$recipe"

Also worth noting: when inputs.containerize-args is empty, the command expands to a bare --containerize (no argument), which relies on Snakemake's argparse nargs='?' default. That works today but is implicit — omitting the flag entirely when the input is empty would be more defensive.

Error handling in this step is intentionally omitted, which aligns with prior feedback that Snakemake itself surfaces proper containerization errors. Based on learnings from PR #39, additional error handling here is unnecessary.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@action.yml` around lines 124 - 130, Normalize the inputs.containerize-args
value before comparing/using it and only append the --containerize flag when it
is non-empty: trim whitespace and lowercase the value (so variants like "
Apptainer" or "APPTAINER" match) and then set recipe="apptainer.def" when the
normalized value equals "apptainer"; otherwise set recipe="Dockerfile". Also
conditionally include the --containerize argument in the snakemake invocation
only when the original/normalized inputs.containerize-args is non-empty to avoid
emitting a bare --containerize flag.

48-51: Tighten the containerize-args description.

The current description is misleading. It says "Additional arguments for --containerize," but this input doesn't add extra arguments—it selects the output format for the --containerize flag. Also, listing '' alongside 'dockerfile' and 'apptainer' obscures the fact that empty means "use Snakemake's default" (currently dockerfile). If Snakemake changes its default in a future version, the hardcoded Dockerfile fallback at line 128 would silently produce a mismatched output.

📝 Proposed wording
   containerize-args:
-    description: Additional arguments for --containerize, can be one of 'dockerfile', 'apptainer' or '' (defaults to dockerfile)
+    description: |
+      Output format to pass to Snakemake's --containerize flag.
+      One of 'dockerfile' or 'apptainer'. If empty, Snakemake's own default is used
+      (currently 'dockerfile'). Selects the recipe filename accordingly
+      (Dockerfile or apptainer.def).
     required: false
     default: ""

Per Snakemake's CLI documentation, --containerize supports only dockerfile (default) and apptainer.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@action.yml` around lines 48 - 51, The input description for
"containerize-args" is misleading: update it to say this input selects the
--containerize output format (allowed values: "dockerfile" or "apptainer") and
that an empty string means "use Snakemake's default" (not an additional
argument); remove the misleading listing of '' as a third explicit option and
clarify the default behavior while keeping default: ""; also update any related
doc comment referencing the hardcoded Dockerfile fallback so it notes that the
fallback is only used when we explicitly override and not assumed when the input
is empty.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@README.md`:
- Around line 23-25: Update the `task` README description to reflect that
`containerize` can produce either a Dockerfile or an Apptainer definition file
by referencing the new `containerize-args` option; change the sentence that
currently says "a container image specification (in the form of a Dockerfile)"
to mention both "a Dockerfile or an Apptainer definition file (e.g.
apptainer.def)" and keep the allowed values (`run` or `containerize`) and
default (`run`) unchanged so the docs align with `containerize-args` behavior.

---

Nitpick comments:
In `@action.yml`:
- Around line 124-130: Normalize the inputs.containerize-args value before
comparing/using it and only append the --containerize flag when it is non-empty:
trim whitespace and lowercase the value (so variants like " Apptainer" or
"APPTAINER" match) and then set recipe="apptainer.def" when the normalized value
equals "apptainer"; otherwise set recipe="Dockerfile". Also conditionally
include the --containerize argument in the snakemake invocation only when the
original/normalized inputs.containerize-args is non-empty to avoid emitting a
bare --containerize flag.
- Around line 48-51: The input description for "containerize-args" is
misleading: update it to say this input selects the --containerize output format
(allowed values: "dockerfile" or "apptainer") and that an empty string means
"use Snakemake's default" (not an additional argument); remove the misleading
listing of '' as a third explicit option and clarify the default behavior while
keeping default: ""; also update any related doc comment referencing the
hardcoded Dockerfile fallback so it notes that the fallback is only used when we
explicitly override and not assumed when the input is empty.

In `@README.md`:
- Around line 43-45: Update the README entry for the input named
"containerize-args" to match the action input description: clarify that it
selects which containerizer to use for containerize (not "additional
arguments"), list the valid options as "dockerfile" or "apptainer" and state the
default is "dockerfile" (do not list '' as a separate option), and add a
trailing period to the sentence; reference the "containerize-args" input and the
"containerize" action when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f691b240-fd76-4563-94a6-d9719630934f

📥 Commits

Reviewing files that changed from the base of the PR and between 5348051 and 440ca6a.

📒 Files selected for processing (3)
  • LICENSE
  • README.md
  • action.yml

@m-jahn m-jahn requested review from dlaehnemann and tedil April 24, 2026 08:56
@m-jahn
Copy link
Copy Markdown
Member Author

m-jahn commented Apr 24, 2026

Just tested the fixed workflow with our automated Apptainer Deployment action
https://github.com/MPUSP/mpusp-github-actions/blob/dev/.github/workflows/deploy-apptainer.yml

... and it worked nicely.

Copy link
Copy Markdown
Contributor

@tedil tedil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) Thank you!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 43-46: The docs and metadata use the invalid value 'dockerfile'
for containerize-args; update the occurrences of the containerize-args
description in README.md and action.yml to state allowed values 'docker' or
'apptainer' (or empty) so that the value passed to snakemake --containerize
matches Snakemake's expected 'docker' token; search for the identifier
containerize-args and change 'dockerfile' to 'docker' in both README and
action.yml and ensure any examples that pass containerize-args to snakemake
--containerize use 'docker' not 'dockerfile'.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4edb5b11-1ebe-45e2-9f6f-1dc499970260

📥 Commits

Reviewing files that changed from the base of the PR and between 440ca6a and 0ea0798.

📒 Files selected for processing (1)
  • README.md

Comment thread README.md
@m-jahn m-jahn merged commit 2e9153a into snakemake:master Apr 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add arguments for the new --containerize functionality

2 participants