Skip to content

fix: add curl when containerize with wrapper#4115

Merged
johanneskoester merged 2 commits intosnakemake:mainfrom
GaspardR:fix-#4114
Mar 19, 2026
Merged

fix: add curl when containerize with wrapper#4115
johanneskoester merged 2 commits intosnakemake:mainfrom
GaspardR:fix-#4114

Conversation

@GaspardR
Copy link
Copy Markdown
Contributor

@GaspardR GaspardR commented Mar 17, 2026

Fixes #4114

--containerize apptainer option from #4030, is used to create apptainer definition file from workflow. When the workflow has rule with wrapper: the image doesn't build, it's missing curl.

Add check for a wrapper rule in workflow and add curl. Add image size optimization if wrapper rule in workflow. Add test for containerize with wrapper.

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).
  • I, as a human being, have checked each line of code in this pull request

AI-assistance disclosure

I used AI assistance for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Summary by CodeRabbit

  • New Features

    • Container images for Apptainer now conditionally install curl when remote environment files are fetched and perform cleanup of package lists to reduce image size.
  • Tests

    • Added test coverage validating Apptainer containerization behavior for wrapper-rule scenarios, including dependency installation and cleanup steps.

Fix snakemake#4114

`--containerize apptainer` option from snakemake#4030, is used to create apptainer definition file from workflow.
When the workflow has rule with `wrapper` the image doesn't build, it's missing `curl`.

Add check for a wrapper rule in workflow and add `curl`.
Add image size optimization if wrapper rule in workflow.
Add test for containerize with wrapper.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a6eef6e4-fe43-48b7-9d7b-cd3c3bc6c21e

📥 Commits

Reviewing files that changed from the base of the PR and between 6af8e5b and 33dab2f.

📒 Files selected for processing (1)
  • src/snakemake/deployment/containerize.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/snakemake/deployment/containerize.py

📝 Walkthrough

Walkthrough

Adds conditional installation of curl and a guarded apt-list cleanup into the Apptainer containerization output when remote environment files are fetched; also adds a test validating generated apptainer.def contains the curl installation and environment source reference.

Changes

Cohort / File(s) Summary
Container curl & cleanup logic
src/snakemake/deployment/containerize.py
Adds detection of remote env fetch need and injects apt-get update + apt-get install -y curl before fetching remote environment files, and appends rm -rf /var/lib/apt/lists/* cleanup guarded by the same condition.
Apptainer wrapper test
tests/tests_using_conda.py
Adds test_containerize_wrapper_apptainer to exercise --containerize apptainer, asserting apptainer.def includes the wrapper environment source and the apt-get/curl steps.

Sequence Diagram(s)

sequenceDiagram
    participant Snakemake
    participant Containerizer
    participant BaseImage
    participant RemoteRepo

    Snakemake->>Containerizer: request containerize (apptainer) for rule with wrapper env
    Containerizer->>BaseImage: emit %post commands
    alt needs_curl == true
        Containerizer->>BaseImage: add "apt-get update" / "apt-get install -y curl"
        BaseImage->>RemoteRepo: curl -L fetch environment.yaml
        RemoteRepo-->>BaseImage: environment.yaml
        Containerizer->>BaseImage: add "rm -rf /var/lib/apt/lists/*"
    else
        BaseImage->>RemoteRepo: (no remote fetch)
    end
    Containerizer-->>Snakemake: write apptainer.def
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding curl when containerizing with wrapper rules for Apptainer.
Description check ✅ Passed The description is comprehensive, includes all required QC checklist items (marked as completed), explains the issue clearly, references the related issue #4114, and includes AI-assistance disclosure.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #4114: detects wrapper rules, installs curl when needed, optimizes image size, and includes test coverage for the functionality.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing issue #4114: modifications to containerize.py handle curl installation for wrapper rules, and the new test validates the containerization with wrappers.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can disable the changed files summary in the walkthrough.

Disable the reviews.changed_files_summary setting to disable the changed files summary in the walkthrough.

@GaspardR GaspardR requested a review from ManarRashad March 17, 2026 22:14
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 `@src/snakemake/deployment/containerize.py`:
- Around line 238-240: The guard using has_wrapper_rule (computed from
workflow.rules) is incorrect; change the condition so curl is installed only
when building an Apptainer image or when any remote environment file requires
curl (e.g. replace has_wrapper_rule with a boolean like needs_curl =
is_apptainer_build() or any(env.is_remote for env in workflow.environments)),
then call formatter.run_command("apt-get update") and
formatter.run_command("apt-get install -y --no-install-recommends curl") only
when needs_curl is true; update the two places referencing has_wrapper_rule to
use this new needs_curl check so Docker builds won’t get apt commands and
Apptainer/remote-env cases are covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5de541ed-8f41-424c-86a7-2bc696ef86c1

📥 Commits

Reviewing files that changed from the base of the PR and between 4bba4a9 and 6af8e5b.

📒 Files selected for processing (2)
  • src/snakemake/deployment/containerize.py
  • tests/tests_using_conda.py

@johanneskoester johanneskoester merged commit 44979e4 into snakemake:main Mar 19, 2026
60 checks passed
@GaspardR GaspardR deleted the fix-#4114 branch March 19, 2026 13:43
johanneskoester pushed a commit that referenced this pull request Mar 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[9.17.3](v9.17.2...v9.17.3)
(2026-03-24)


### Bug Fixes

* add curl when containerize with wrapper
([#4115](#4115))
([44979e4](44979e4))
* ensure proper wrapper prefix is passed to CWL and shown in wrapper
error messages
([#4121](#4121))
([11b6f29](11b6f29))
* ensure that strings that purely contain integers or floats (e.g. "42")
remain strings when parsing profiles
([#4119](#4119))
([3ca08e1](3ca08e1))
* incorrect highlighting in HTML report
([#4120](#4120))
([1ef224d](1ef224d))


### Documentation

* document an accidental (sorry) recent breaking change in type checking
compatibility of Python scripts, in favor of a clean and robust new
syntax ([#4116](#4116))
([013bc43](013bc43))
* Rework tutorial
([#4068](#4068))
([4bba4a9](4bba4a9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Released version 9.17.3

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

curl not present in condaforge/miniforge3:latest

2 participants