Skip to content

fix: group job error call#3448

Merged
cademirch merged 3 commits into
mainfrom
fix-group-job-error
Mar 14, 2025
Merged

fix: group job error call#3448
cademirch merged 3 commits into
mainfrom
fix-group-job-error

Conversation

@cademirch

@cademirch cademirch commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

This wasn't caught earlier, likely due to how we check for tests that expect failure. The test_group_jobs_fail test was failing, but it was b/c of this issue. Perhaps should check for the expected exception.

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
    • Enhanced error logging to display grouped job errors in a sorted, consistent order for clearer troubleshooting.
    • Introduced tailored error logging during job scheduling, ensuring that errors for grouped jobs are handled separately for improved clarity.

@coderabbitai

coderabbitai Bot commented Mar 14, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes enhance error logging within the job processing workflow. In the GroupJob class, the log_error method now iterates over its jobs attribute, sorting them by rule name and logging each error with indentation. Meanwhile, the JobScheduler class in the scheduler module now distinguishes between GroupJob instances and other job types when logging errors by conditionally invoking the enhanced log_error for group jobs. The changes refine the error reporting by providing an ordered, detailed logging approach specifically for grouped jobs.

Changes

Files Change Summary
src/snakemake/jobs.py Added a loop in the GroupJob.log_error method to iterate over the jobs attribute, sort jobs by their rule names, and call each job’s log_error with the indent=True parameter.
src/snakemake/scheduler.py Introduced a conditional check in the JobScheduler.schedule method to determine if a job is a GroupJob and, if so, call its enhanced log_error method; added import for GroupJob.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler as JobScheduler
    participant Group as GroupJob
    participant Job as Individual Job

    Scheduler->>Scheduler: schedule(job)
    alt Job is a GroupJob
        Scheduler->>Group: log_error(msg, indent, aux_logs, ...)
        Group->>Group: Sort jobs by rule name
        loop For each sorted job
            Group->>Job: log_error(msg, indent=True, ...)
        end
    else Job is not a GroupJob
        Scheduler->>Scheduler: Use standard error logging
    end
Loading

Suggested reviewers

  • johanneskoester

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent 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 c54a70f.

📒 Files selected for processing (2)
  • src/snakemake/jobs.py (1 hunks)
  • src/snakemake/scheduler.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/scheduler.py
  • src/snakemake/jobs.py
⏰ Context from checks skipped due to timeout of 90000ms (35)
  • GitHub Check: tests (10, macos-latest, py312)
  • GitHub Check: tests (10, windows-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (9, windows-latest, py312)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (8, windows-latest, py312)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (7, windows-latest, py312)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (6, windows-latest, py312)
  • 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, macos-latest, py312)
  • 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, macos-latest, py312)
  • 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, macos-latest, py312)
  • GitHub Check: tests (1, windows-latest, py312)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: apidocs
🔇 Additional comments (3)
src/snakemake/scheduler.py (2)

25-25: Good addition of the GroupJob import

This import is necessary for the type checking in the error handling logic.


220-226: Good implementation of specialized error handling for GroupJob

This change enhances error reporting by handling GroupJob instances and regular jobs differently. For GroupJob instances, it uses the specialized log_error method, while for other jobs it maintains the existing error logging mechanism.

The implementation correctly uses isinstance() for type checking and ensures that each job type gets the appropriate error logging treatment.

src/snakemake/jobs.py (1)

1480-1481: Improved error reporting for group jobs

This enhancement improves error clarity by sorting jobs by rule name before logging errors, which makes error messages more readable and consistent. The indentation parameter ensures proper formatting in the output.

This change complements the conditional handling in the scheduler.py file, creating a complete solution for better group job error reporting.

✨ Finishing Touches
  • 📝 Generate Docstrings

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

@cademirch cademirch merged commit 3d53863 into main Mar 14, 2025
@cademirch cademirch deleted the fix-group-job-error branch March 14, 2025 23:49
johanneskoester pushed a commit that referenced this pull request Mar 15, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.0.1](v9.0.0...v9.0.1)
(2025-03-14)


### Bug Fixes

* group job error call
([#3448](#3448))
([3d53863](3d53863))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
kjohnsen pushed a commit to kjohnsen/snakemake that referenced this pull request Dec 15, 2025
This wasn't caught earlier, likely due to how we check for tests that
expect failure. The `test_group_jobs_fail` test was failing, but it was
b/c of this issue. Perhaps should check for the expected exception.
### 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.
* [ ] 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**
- Enhanced error logging to display grouped job errors in a sorted,
consistent order for clearer troubleshooting.
- Introduced tailored error logging during job scheduling, ensuring that
errors for grouped jobs are handled separately for improved clarity.

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

Co-authored-by: Johannes Köster <johannes.koester@tu-dortmund.de>
kjohnsen pushed a commit to kjohnsen/snakemake that referenced this pull request Dec 15, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.0.1](snakemake/snakemake@v9.0.0...v9.0.1)
(2025-03-14)


### Bug Fixes

* group job error call
([snakemake#3448](snakemake#3448))
([3d53863](snakemake@3d53863))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants