Skip to content

fix: unify error logging in scheduler, fixing a missing attribute error for group jobs#3515

Merged
johanneskoester merged 1 commit intomainfrom
fix/log-error
Apr 7, 2025
Merged

fix: unify error logging in scheduler, fixing a missing attribute error for group jobs#3515
johanneskoester merged 1 commit intomainfrom
fix/log-error

Conversation

@johanneskoester
Copy link
Copy Markdown
Contributor

@johanneskoester johanneskoester commented Apr 7, 2025

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

  • Refactor
    • Revised error logging in the job scheduling process by removing distinctions based on job type. All failed jobs are now handled uniformly, leading to more consistent and clear error reporting. These changes facilitate improved diagnostics and system maintainability, ultimately supporting a transparent and reliable user experience.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 2025

📝 Walkthrough

Walkthrough

The pull request refactors the error logging in the schedule method of the JobScheduler class. It removes the conditional branch that previously distinguished between GroupJob instances and other job types. Now, the method uniformly calls the log_error() method on every job in the self.failed set, simplifying the error handling logic.

Changes

File Path Change Summary
src/snakemake/scheduler.py Removed conditional checks distinguishing GroupJob from other jobs. Now, all failed jobs call log_error() uniformly.

Sequence Diagram(s)

sequenceDiagram
    participant JS as JobScheduler
    participant Job as Job Instance
    JS->>+Job: Invoke log_error() on each job in self.failed
    Job-->>-JS: Log error
Loading

Possibly related PRs

  • fix: group job error call #3448: Addresses enhancements in error logging by modifying error handling specifically for GroupJob instances, showing a direct connection to the unified logging approach in this PR.

📜 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 facf24a and c985363.

📒 Files selected for processing (1)
  • src/snakemake/scheduler.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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 `s...

**/*.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
🧬 Code Definitions (1)
src/snakemake/scheduler.py (1)
src/snakemake/jobs.py (2)
  • log_error (1156-1162)
  • log_error (1465-1481)
⏰ Context from checks skipped due to timeout of 90000ms (22)
  • GitHub Check: tests (10, windows-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • 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, 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)
🔇 Additional comments (2)
src/snakemake/scheduler.py (2)

221-221: Clean and consistent error logging.

The change simplifies error handling by uniformly calling log_error() on all job types without checking if a job is a GroupJob. This approach leverages polymorphism correctly, as the log_error() implementation in each job type will handle the appropriate logging logic.

Previously, there was likely conditional code here that handled GroupJob instances differently, which could have caused the missing attribute error mentioned in the PR objectives.


238-238: Consistent error handling approach.

Same improvement as in line 221 - unifying the error handling approach by directly calling log_error() on each job. Based on the relevant code snippets from jobs.py, both regular jobs and group jobs implement this method appropriately for their respective types.

The GroupJob.log_error() method (from the relevant code snippets) already handles proper logging for all jobs in the group, making the previous conditional code unnecessary.

✨ 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 plan to trigger planning for file edits and PR creation.
  • @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.

@johanneskoester johanneskoester merged commit 245ec10 into main Apr 7, 2025
49 checks passed
@johanneskoester johanneskoester deleted the fix/log-error branch April 7, 2025 09:25
johanneskoester pushed a commit that referenced this pull request Apr 7, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.1.8](v9.1.7...v9.1.8)
(2025-04-07)


### Bug Fixes

* improve labelling of input and output files when logging rules
([#3516](#3516))
([56203a4](56203a4))
* unify error logging in scheduler, fixing a missing attribute error for
group jobs ([#3515](#3515))
([245ec10](245ec10))


### Documentation

* activate gurubase AI
([#3517](#3517))
([eaffc6e](eaffc6e))

---
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
…or for group jobs (snakemake#3515)

### 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

- **Refactor**
- Revised error logging in the job scheduling process by removing
distinctions based on job type. All failed jobs are now handled
uniformly, leading to more consistent and clear error reporting. These
changes facilitate improved diagnostics and system maintainability,
ultimately supporting a transparent and reliable user experience.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
kjohnsen pushed a commit to kjohnsen/snakemake that referenced this pull request Dec 15, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.1.8](snakemake/snakemake@v9.1.7...v9.1.8)
(2025-04-07)


### Bug Fixes

* improve labelling of input and output files when logging rules
([snakemake#3516](snakemake#3516))
([56203a4](snakemake@56203a4))
* unify error logging in scheduler, fixing a missing attribute error for
group jobs ([snakemake#3515](snakemake#3515))
([245ec10](snakemake@245ec10))


### Documentation

* activate gurubase AI
([snakemake#3517](snakemake#3517))
([eaffc6e](snakemake@eaffc6e))

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

1 participant