docs: Added guide on debugging workflows#4029
Conversation
<!--Add a description of your PR here--> Added a docs page on debugging workflows: - log file locations - faster DAG resolution - interactive debugging ### QC <!-- Make sure that you can tick the boxes below. --> * [ ] The PR contains a test case for the changes or the changes are already covered by an existing test case. **Not applicable - only documentation affected** * [X] 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).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds a new documentation page describing debugging workflows for Snakemake and registers it in the docs index under "Defining workflows". The page covers log locations, per-job logs, STDERR redirection, R backtraces, VS Code interactive debugging, breakpoints, and wrapper-script preservation. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
<!--Add a description of your PR here--> Added section on preserving wrapper scripts ### QC <!-- Make sure that you can tick the boxes below. --> * [ ] The PR contains a test case for the changes or the changes are already covered by an existing test case. **Docs only** * [x] 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).
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/snakefiles/debugging_workflows.rst`:
- Line 77: Docs have small typos: remove the duplicated word "with" in the
sentence containing "Visual Studio Code <https://code.visualstudio.com/> editor
comes with with", remove the extra period in the phrase "variables.." (make it
"variables."), and replace the incorrect "library() s" token with "library()" or
"library() calls" for correct wording; update those three occurrences (the
fragments "with with", "variables..", and "library() s") accordingly in the
documentation.
- Around line 100-111: The VS Code launch snippet incorrectly sets "program":
"-m" and passes "snakemake" in the "args" list; update the launch configuration
to use "module": "snakemake" (remove the "program" entry) and remove "snakemake"
from the "args" array so the Snakemake module is launched via the "module"
field; ensure other args like "--debug", "--cores", "--nolock", "--forceall",
and "--executor" remain in "args" and keep "python":
"${command:python.interpreterPath}" as-is.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bd277526-3cb0-4990-a784-f96bc2cd0cc8
📒 Files selected for processing (2)
docs/index.rstdocs/snakefiles/debugging_workflows.rst
There was a problem hiding this comment.
♻️ Duplicate comments (1)
docs/snakefiles/debugging_workflows.rst (1)
150-150:⚠️ Potential issue | 🟡 MinorFix awkward phrasing: "library() s".
The phrasing "library() s" is awkward. Consider rephrasing to one of:
- "load all the libraries you need"
- "load all the
library()calls you need"- "call all the
library()functions you need"📝 Suggested fix
-Start an interactive R session and load all the ``library()`` s that you need for the script. Then you can load the full workspace and interactively explore / debug what's going on: +Start an interactive R session and load all the libraries you need for the script. Then you can load the full workspace and interactively explore / debug what's going on:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/snakefiles/debugging_workflows.rst` at line 150, The sentence "load all the ``library()`` s that you need" uses awkward spacing and pluralization; update the wording in docs/snakefiles/debugging_workflows.rst to a clearer phrase such as "load all the libraries you need", "call all the `library()` functions you need", or "load all the `library()` calls you need" and ensure the inline code formatting remains for `library()` where appropriate (reference symbol: library()).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@docs/snakefiles/debugging_workflows.rst`:
- Line 150: The sentence "load all the ``library()`` s that you need" uses
awkward spacing and pluralization; update the wording in
docs/snakefiles/debugging_workflows.rst to a clearer phrase such as "load all
the libraries you need", "call all the `library()` functions you need", or "load
all the `library()` calls you need" and ensure the inline code formatting
remains for `library()` where appropriate (reference symbol: library()).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 520eef59-a74f-4692-959c-2ff796e0b822
📒 Files selected for processing (2)
docs/index.rstdocs/snakefiles/debugging_workflows.rst
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/index.rst
dlaehnemann
left a comment
There was a problem hiding this comment.
This looks good, thanks for taking the time to bring this together. I mostly have some minor suggestions, and on thing that will especially make further reviewing and editing easier:
We generally try to have one sentence per line. That way the diffs are easier to read.
But only apply that once you've gone through the suggestions, as they might otherwise not be rendered correctly any more...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Depending on the executor you are using, additional log files may be generated for each job. | ||
| For the location thereof, please refer to the documentation of the respective executor. |
There was a problem hiding this comment.
I would add a linkout to the plugin catalog, here:
| For the location thereof, please refer to the documentation of the respective executor. | |
| For the location thereof, please refer to the `documentation of the respective executor pluging <https://snakemake.github.io/snakemake-plugin-catalog/>`_. |
|
|
||
| To now debug your workflow: | ||
|
|
||
| 1. Add breakpoints to your Snakefile by adding ``breakpoint()`` statements wherever you want to halt execution to inspect the state of the workflow. |
There was a problem hiding this comment.
Maybe add an example here, for example using the breakpoint in the onerror handler, linking out to the respective docs in the test:
https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#onstart-onsuccess-and-onerror-handlers
You can use the :ref: syntax and the hyperlink target snakefiles-job_lifetime_handlers.
|
|
||
| **For R scripts / run blocks:** | ||
|
|
||
| You can save the entire current state of a workspace in R, for debugging you can insert this line right before some code triggers an error: |
There was a problem hiding this comment.
| You can save the entire current state of a workspace in R, for debugging you can insert this line right before some code triggers an error: | |
| You can save the entire current state of a workspace in R for debugging. | |
| Insert this line right before some code triggers an error: |
| save.image(file = "my_dump.RData") | ||
|
|
||
|
|
||
| Start an interactive R session and load all the ``library()`` s that you need for the script. Then you can load the full workspace and interactively explore / debug what's going on: |
There was a problem hiding this comment.
| Start an interactive R session and load all the ``library()`` s that you need for the script. Then you can load the full workspace and interactively explore / debug what's going on: | |
| Activate the conda environment that the rule uses (you can find this in the logging output, with a statement starting with ``Activating conda environment: ``) and start an interactive R session. | |
| In this session, load all the ``library()`` s that you need for the script. | |
| Then you can load the full workspace and interactively explore / debug what's going on: |
Closes #4013 .
Added a docs page on debugging workflows:
scriptrule wrapper scriptsQC
Not applicable - only documentation affected
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).Summary by CodeRabbit