Skip to content

fix(docs): make Data-dependent conditional execution a complete example#4043

Merged
johanneskoester merged 1 commit intosnakemake:mainfrom
clelange:rules_examples
Mar 11, 2026
Merged

fix(docs): make Data-dependent conditional execution a complete example#4043
johanneskoester merged 1 commit intosnakemake:mainfrom
clelange:rules_examples

Conversation

@clelange
Copy link
Copy Markdown
Contributor

@clelange clelange commented Mar 10, 2026

  • Also fix indentation errors for another code snippet
  • 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).

Fixes #4042

Summary by CodeRabbit

  • Documentation
    • Updated checkpoint examples to illustrate dynamic sample generation and data-dependent workflows.
    • Improved code formatting and readability across checkpoint-related documentation.
    • Enhanced explanations for handling dynamically generated file outputs and wildcard expansion patterns.

- Also fix indentation errors for another code snippet
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

Documentation update to Snakemake's data-dependent checkpoint section, making the incomplete example more practical. Introduced dynamic sample generation, updated checkpoint and downstream rule wiring, fixed indentation issues, and added explanatory notes for handling checkpoint outputs.

Changes

Cohort / File(s) Summary
Documentation - Data-dependent Checkpoint Example
docs/snakefiles/rules.rst
Updated incomplete example in the data-dependent conditional execution section. Replaced static aggregated inputs with dynamically generated samples. Introduced new generate_sample_input rule, modified somestep checkpoint to process dynamic samples via cp {input} {output}, and updated aggregate_input rule for data-driven path decisions. Fixed indentation errors, standardized code block formatting, and added explanatory notes on handling unknown numbers of checkpoint files using directory outputs and wildcard expansion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete, missing the QC section header and containing only partial checklist items without a proper formatted section. Add the QC section header and format the checklist properly with both items, explaining why tests are unnecessary or already covered.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: completing a documentation example and fixing indentation errors.
Linked Issues check ✅ Passed The PR directly addresses issue #4042 by completing the data-dependent conditional execution documentation example and fixing identified indentation errors.
Out of Scope Changes check ✅ Passed All changes are within scope: completing the documentation example and fixing indentation errors as specified in issue #4042.
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
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

🧹 Nitpick comments (1)
docs/snakefiles/rules.rst (1)

2986-2990: Shell command might benefit from explicit path or command chaining.

The current shell script uses cd my_directory followed by touch $i.txt. While this may work if all commands execute in the same shell session, it's more robust to either:

  1. Use explicit paths: mkdir -p my_directory/ && for i in 1 2 3; do touch my_directory/$i.txt; done
  2. Chain commands explicitly: mkdir my_directory/ && (cd my_directory && for i in 1 2 3; do touch $i.txt; done)

This makes the intent clearer and ensures files are created in the correct location regardless of shell execution context.

🔧 Suggested improvements
-      shell:'''
-      mkdir my_directory/
-      cd my_directory
-      for i in 1 2 3; do touch $i.txt; done
-      '''
+      shell:
+          """
+          mkdir -p my_directory/
+          for i in 1 2 3; do touch my_directory/$i.txt; done
+          """

Or alternatively:

-      shell:'''
-      mkdir my_directory/
-      cd my_directory
-      for i in 1 2 3; do touch $i.txt; done
-      '''
+      shell:
+          "mkdir -p my_directory/ && (cd my_directory && for i in 1 2 3; do touch $i.txt; done)"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/snakefiles/rules.rst` around lines 2986 - 2990, The shell block
containing the commands "mkdir my_directory/", "cd my_directory", and "for i in
1 2 3; do touch $i.txt; done" is fragile because it relies on a persistent shell
state; update that block to be explicit by either creating the directory with
mkdir -p and touching files with explicit paths (e.g., touch my_directory/$i.txt
in the for loop) or by chaining commands with && and a subshell (e.g., mkdir
my_directory && (cd my_directory && for ...; done)) so file creation cannot fail
due to shell execution context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/snakefiles/rules.rst`:
- Around line 2986-2990: The shell block containing the commands "mkdir
my_directory/", "cd my_directory", and "for i in 1 2 3; do touch $i.txt; done"
is fragile because it relies on a persistent shell state; update that block to
be explicit by either creating the directory with mkdir -p and touching files
with explicit paths (e.g., touch my_directory/$i.txt in the for loop) or by
chaining commands with && and a subshell (e.g., mkdir my_directory && (cd
my_directory && for ...; done)) so file creation cannot fail due to shell
execution context.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6d0e614c-f563-4f73-842d-66eefb6e255a

📥 Commits

Reviewing files that changed from the base of the PR and between d3430b9 and d2a1470.

📒 Files selected for processing (1)
  • docs/snakefiles/rules.rst

@johanneskoester
Copy link
Copy Markdown
Contributor

Thanks!!

@johanneskoester johanneskoester merged commit 3a1d7f2 into snakemake:main Mar 11, 2026
60 checks passed
@clelange clelange mentioned this pull request Mar 12, 2026
johanneskoester pushed a commit that referenced this pull request Mar 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[9.17.0](v9.16.3...v9.17.0)
(2026-03-13)


### Features

* Allow storing snakemake metadata in files or databases
([#4012](#4012))
([dd75f31](dd75f31))
* Allow to specify comparison command per-unit test
([#3956](#3956))
([b88171c](b88171c))
* job table orderd topological when run is started
([#4018](#4018))
([75cf506](75cf506))
* lambda functions for priority in rules
([#3253](#3253))
([d2aa226](d2aa226))
* Make on... directive of modules accessible
([#4050](#4050))
([e9f2e1c](e9f2e1c))


### Bug Fixes

* adjust conda tests to not fail on apple silicon; fix
[#4040](#4040)
([#4049](#4049))
([f5b0142](f5b0142))
* allow "--containerize apptainer" to output apptainer format instead of
dockerfile ([#4030](#4030))
([f5cac30](f5cac30))
* apptainer command not recognized when singularity is absent
([#4010](#4010))
([b8162e2](b8162e2))
* capture stderr when tests fail
([#3995](#3995))
([97d74ba](97d74ba))
* **docs:** make Data-dependent conditional execution a complete example
([#4043](#4043))
([3a1d7f2](3a1d7f2))
* don't build the DAG when running unlock. Fixes
[#4000](#4000) and
[#198](#198)
([#4007](#4007))
([acf79fd](acf79fd))
* Ensure pixi tasks may be run as advertised
([#4046](#4046))
([88253c2](88253c2))
* fix checkpoint handling corner cases
([#3870](#3870) and
[#3559](#3559))
([#4015](#4015))
([63f4257](63f4257))
* issue 3642
([#4054](#4054))
([76e6fc2](76e6fc2))
* issue 3815
([#4026](#4026))
([b0eec96](b0eec96))
* logging None in shellcmd context causes error
([#4064](#4064))
([d0652cd](d0652cd))
* lookup function returns default value for empty DataFrame queries
([#4056](#4056))
([f71de97](f71de97))
* make `cache: omit-software` a rule specific property
([#4085](#4085))
([034a9e7](034a9e7))
* reduce number of tests leaving temporary files behind
([#4033](#4033))
([a3a1c97](a3a1c97))
* regression in dynamic resource handling
([#4038](#4038))
([f2c554a](f2c554a))
* somewhat shorter announce message
([#4080](#4080))
([57efc71](57efc71))


### Performance Improvements

* switch reretry with tenacity; decouple container classes (with Python
3.7 compat for old scripts) from rest of the codebase (enabling moving
to newer python versions)
([#4032](#4032))
([ffb19e7](ffb19e7))


### Documentation

* Add AI-assisted contributions policy to contributing guidelines
([#4051](#4051))
([dd70526](dd70526))
* **codebase:** Update & simplify plugin architecture section
([#4052](#4052))
([176cf63](176cf63))
* Correct workflow.source_path() description in documentation
([#4036](#4036))
([45883c5](45883c5))
* fixed wrong code example for collect() function
([#4037](#4037))
([5c85ed8](5c85ed8))
* Minor docs improvements
([#4089](#4089))
([29ea226](29ea226))
* switch to sphinx_design for tabs
([#3976](#3976))
([9674614](9674614))
* typo in the migration table breaking a pip install command
([#4024](#4024))
([66f9dda](66f9dda))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
johanneskoester added a commit that referenced this pull request Mar 14, 2026
Following up on PR #4043

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

## Summary by CodeRabbit

* **Documentation**
* Updated shell command example in documentation to use the `-p` flag
for directory creation, ensuring the command executes reliably when
directories already exist.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Johannes Köster <johannes.koester@tu-dortmund.de>
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.

docs: Data-dependent conditional execution is not a complete example

2 participants