Skip to content

chore: dbg sh fail#3447

Merged
johanneskoester merged 3 commits into
mainfrom
dbg/sh-fail
Mar 14, 2025
Merged

chore: dbg sh fail#3447
johanneskoester merged 3 commits into
mainfrom
dbg/sh-fail

Conversation

@johanneskoester

@johanneskoester johanneskoester commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

Description

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).

Summary by CodeRabbit

  • New Features
    • The script now displays the initial input parameter before execution, offering clearer feedback on its usage.
  • Bug Fixes
    • Enhanced error handling by preventing callable values from being used as settings in spawned jobs.

@coderabbitai

coderabbitai Bot commented Mar 14, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The script located in tests/test_issue860/qsub has been updated by adding a new line that echoes the first argument ($1) provided to the script. This additional command is placed before the execution of the shell script specified by the argument, ensuring that the value of the argument is printed out while leaving the overall script flow intact. Additionally, in src/snakemake/spawn_jobs.py, a new import statement for WorkflowError has been introduced, and a conditional check was added in the _get_storage_provider_setting_items method to raise a WorkflowError if a callable value is passed as a setting.

Changes

File(s) Change Summary
tests/.../qsub Added an echo line to print the first argument ($1) before executing the specified shell script.
src/snakemake/spawn_jobs.py Added import for WorkflowError. Introduced a conditional check in _get_storage_provider_setting_items to raise a WorkflowError if a callable value is passed.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/System
    participant QSUB as Script (qsub)
    participant Shell as ShellScript

    User ->> QSUB: Call with argument ($1)
    QSUB ->> QSUB: Echo $1
    QSUB ->> Shell: Execute script specified by $1
Loading
sequenceDiagram
    participant Workflow as Workflow
    participant SpawnJobs as SpawnJobs

    Workflow ->> SpawnJobs: Request storage provider setting items
    SpawnJobs ->> SpawnJobs: Check if value is callable
    alt Value is callable
        SpawnJobs -->> Workflow: Raise WorkflowError
    else Value is not callable
        SpawnJobs -->> Workflow: Return setting items
    end
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/test_issue860/qsub (1)

7-7: Enhance Debug Output Robustness

The addition of echo $1 is useful for debugging purposes by printing the provided argument before executing it. However, to avoid potential word-splitting or misinterpretation when $1 contains spaces or special characters, please consider quoting it (e.g., echo "$1").

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d778fb and c1af47e.

📒 Files selected for processing (1)
  • tests/test_issue860/qsub (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: tests (10, windows-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (5, windows-latest, py312)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (4, windows-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (3, windows-latest, py312)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (2, windows-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (1, windows-latest, py312)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: apidocs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1af47e and 17d788f.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (1)
  • src/snakemake/spawn_jobs.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.py`: Do not try to improve formatting. Do not suggest ...

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

  • src/snakemake/spawn_jobs.py
🪛 Ruff (0.8.2)
src/snakemake/spawn_jobs.py

61-61: Function definition does not bind loop variable plugin_name

(B023)

🔇 Additional comments (1)
src/snakemake/spawn_jobs.py (1)

14-14: LGTM: Import added for WorkflowError

This import is appropriately added to support the new error handling in the _get_storage_provider_setting_items method.

Comment on lines +59 to +63
if callable(value):
raise WorkflowError(
f"Invalid setting for plugin {plugin_name}. Unable "
"to pass callable value as a setting to spawned jobs."
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the potential closure issue with the plugin_name variable

The added check that prevents callable values from being passed as settings is valuable, but there's a potential issue: the nested fmt_value function uses the loop variable plugin_name in the error message, which is flagged by the static analyzer as B023 (function definition does not bind loop variable).

When the function is called later, it may use the last value of plugin_name from the loop instead of the value at the time of function definition.

To fix this, pass plugin_name as a parameter to the function:

-                    def fmt_value(tag, value):
+                    def fmt_value(tag, value, current_plugin=plugin_name):
                         if callable(value):
                             raise WorkflowError(
-                                f"Invalid setting for plugin {plugin_name}. Unable "
+                                f"Invalid setting for plugin {current_plugin}. Unable "
                                 "to pass callable value as a setting to spawned jobs."
                             )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if callable(value):
raise WorkflowError(
f"Invalid setting for plugin {plugin_name}. Unable "
"to pass callable value as a setting to spawned jobs."
)
def fmt_value(tag, value, current_plugin=plugin_name):
if callable(value):
raise WorkflowError(
f"Invalid setting for plugin {current_plugin}. Unable "
"to pass callable value as a setting to spawned jobs."
)
🧰 Tools
🪛 Ruff (0.8.2)

61-61: Function definition does not bind loop variable plugin_name

(B023)

@johanneskoester johanneskoester merged commit 0a75d6c into main Mar 14, 2025
@johanneskoester johanneskoester deleted the dbg/sh-fail branch March 14, 2025 18:01
kjohnsen pushed a commit to kjohnsen/snakemake that referenced this pull request Dec 15, 2025
### Description

<!--Add a description of your PR here-->

### QC
<!-- Make sure that you can tick the boxes below. -->

* [x] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [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).


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

- **New Features**
- The script now displays the initial input parameter before execution,
offering clearer feedback on its usage.
- **Bug Fixes**
- Enhanced error handling by preventing callable values from being used
as settings in spawned jobs.
<!-- 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.

1 participant