Skip to content

fix: rerun jobs if previously failed but rule was changed afterwards (thanks to @laf070810 for bringing this up)#3237

Merged
johanneskoester merged 3 commits intomainfrom
fix/rerun-failed-but-changed
Dec 21, 2024
Merged

fix: rerun jobs if previously failed but rule was changed afterwards (thanks to @laf070810 for bringing this up)#3237
johanneskoester merged 3 commits intomainfrom
fix/rerun-failed-but-changed

Conversation

@johanneskoester
Copy link
Copy Markdown
Contributor

@johanneskoester johanneskoester commented Dec 21, 2024

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

    • Introduced a new Snakemake workflow with rules for generating intermediate files and handling conditional failures.
    • Added a new test function to validate job metadata persistence during error scenarios.
  • Bug Fixes

    • Streamlined error handling in job completion processes to enhance clarity and efficiency.
  • Documentation

    • Updated expected results for tests to reflect new workflows and configurations.
  • Chores

    • Adjusted temporary directory handling in test functions for improved flexibility.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 21, 2024

📝 Walkthrough

Walkthrough

The pull request introduces modifications across multiple files in the Snakemake project, focusing on improving error handling and testing mechanisms. The changes primarily involve updating the job processing logic in jobs.py, enhancing the run function in tests/common.py, adding a new test workflow in test_failed_intermediate/Snakefile, and introducing a comprehensive test case in tests/tests.py to validate job metadata persistence during error scenarios.

Changes

File Change Summary
snakemake/jobs.py Modified postprocess method to simplify error handling and job completion status recording
tests/common.py Updated run function to handle tmpdir parameter more flexibly
tests/test_failed_intermediate/Snakefile Added new workflow rules with configurable failure scenarios
tests/test_failed_intermediate/expected-results/test3.txt Added false as the expected test result
tests/tests.py Introduced test_failed_intermediate function to test job metadata handling during errors

Sequence Diagram

sequenceDiagram
    participant Job
    participant Storage
    participant ErrorHandler
    
    Job->>ErrorHandler: Attempt job processing
    alt Job Successful
        Job->>Storage: Record job completion
    else Job Failed
        alt keep_incomplete is False
            Job->>Storage: Clean up metadata
        end
        ErrorHandler->>Job: Handle and log error
    end
Loading

The sequence diagram illustrates the enhanced job processing flow, showing how job completion and error handling are now managed more systematically, with conditional metadata cleanup based on the keep_incomplete setting.

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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.

@github-actions
Copy link
Copy Markdown
Contributor

Please format your code with black: black snakemake tests/*.py.

@johanneskoester johanneskoester changed the title fix: rerun jobs if previously failed but rule was changed afterwards fix: rerun jobs if previously failed but rule was changed afterwards (thanks to @laf070810 for bringing this up) Dec 21, 2024
@sonarqubecloud
Copy link
Copy Markdown

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.

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 e8a0b83 and 5ecd4ee.

📒 Files selected for processing (5)
  • snakemake/jobs.py (1 hunks)
  • tests/common.py (2 hunks)
  • tests/test_failed_intermediate/Snakefile (1 hunks)
  • tests/test_failed_intermediate/expected-results/test3.txt (1 hunks)
  • tests/tests.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/test_failed_intermediate/expected-results/test3.txt
👮 Files not reviewed due to content moderation or server errors (3)
  • tests/test_failed_intermediate/Snakefile
  • tests/common.py
  • tests/tests.py
🧰 Additional context used
📓 Path-based instructions (3)
tests/tests.py (1)

Pattern **/*.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.

tests/common.py (1)

Pattern **/*.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.

snakemake/jobs.py (1)

Pattern **/*.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.

🪛 Ruff (0.8.2)
snakemake/jobs.py

1195-1199: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

🔇 Additional comments (1)
snakemake/jobs.py (1)

1192-1199: LGTM! The changes correctly implement job metadata recording.

The implementation properly handles job completion metadata recording and cleanup, which is essential for the feature of rerunning failed jobs when rules are changed.

🧰 Tools
🪛 Ruff (0.8.2)

1195-1199: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)

@johanneskoester johanneskoester merged commit 1dc0084 into main Dec 21, 2024
@johanneskoester johanneskoester deleted the fix/rerun-failed-but-changed branch December 21, 2024 15:04
johanneskoester pushed a commit that referenced this pull request Dec 23, 2024
🤖 I have created a release *beep* *boop*
---


##
[8.26.0](v8.25.5...v8.26.0)
(2024-12-23)


### Features

* add helpers for deferred input/output etc. item access
([#2927](#2927))
([2cca9bc](2cca9bc))


### Bug Fixes

* convert parameters so they can be serialized
([#2925](#2925))
([9e653fb](9e653fb))
* correct formatting of R preamble
([#2425](#2425))
([5380cae](5380cae))
* fix modification checks for scripts and and notebooks containing
wildcards or params in their paths
([#2751](#2751))
([773568d](773568d))
* Improved handling of missing output files in group job postprocessing,
accounting for temporary files.
([#1765](#1765))
([bac06ba](bac06ba))
* mtime of script or notebook not triggering workflow without metadata
([#3148](#3148))
([e8a0b83](e8a0b83))
* Pass `host` attribute to `GitlabFile` instantiation within class
methods ([#3155](#3155))
([9ef52de](9ef52de))
* problem with spaces in path
([#3236](#3236))
([2d08c63](2d08c63))
* require current yte release which contains an important bug fix for
cases where numpy/pandas data is passed to templates
([#3227](#3227))
([c3339da](c3339da))
* rerun jobs if previously failed but rule was changed afterwards
(thanks to [@laf070810](https://github.com/laf070810) for bringing this
up) ([#3237](#3237))
([1dc0084](1dc0084))
* use relpath for configfiles added to the source archive (thanks to
[@sposadac](https://github.com/sposadac) for the initial solution)
([#3240](#3240))
([bff3844](bff3844))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kjohnsen pushed a commit to kjohnsen/snakemake that referenced this pull request Dec 15, 2025
…(thanks to @laf070810 for bringing this up) (snakemake#3237)

<!--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**
- Introduced a new Snakemake workflow with rules for generating
intermediate files and handling conditional failures.
- Added a new test function to validate job metadata persistence during
error scenarios.

- **Bug Fixes**
- Streamlined error handling in job completion processes to enhance
clarity and efficiency.

- **Documentation**
- Updated expected results for tests to reflect new workflows and
configurations.

- **Chores**
- Adjusted temporary directory handling in test functions for improved
flexibility.

<!-- 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*
---


##
[8.26.0](snakemake/snakemake@v8.25.5...v8.26.0)
(2024-12-23)


### Features

* add helpers for deferred input/output etc. item access
([snakemake#2927](snakemake#2927))
([2cca9bc](snakemake@2cca9bc))


### Bug Fixes

* convert parameters so they can be serialized
([snakemake#2925](snakemake#2925))
([9e653fb](snakemake@9e653fb))
* correct formatting of R preamble
([snakemake#2425](snakemake#2425))
([5380cae](snakemake@5380cae))
* fix modification checks for scripts and and notebooks containing
wildcards or params in their paths
([snakemake#2751](snakemake#2751))
([773568d](snakemake@773568d))
* Improved handling of missing output files in group job postprocessing,
accounting for temporary files.
([snakemake#1765](snakemake#1765))
([bac06ba](snakemake@bac06ba))
* mtime of script or notebook not triggering workflow without metadata
([snakemake#3148](snakemake#3148))
([e8a0b83](snakemake@e8a0b83))
* Pass `host` attribute to `GitlabFile` instantiation within class
methods ([snakemake#3155](snakemake#3155))
([9ef52de](snakemake@9ef52de))
* problem with spaces in path
([snakemake#3236](snakemake#3236))
([2d08c63](snakemake@2d08c63))
* require current yte release which contains an important bug fix for
cases where numpy/pandas data is passed to templates
([snakemake#3227](snakemake#3227))
([c3339da](snakemake@c3339da))
* rerun jobs if previously failed but rule was changed afterwards
(thanks to [@laf070810](https://github.com/laf070810) for bringing this
up) ([snakemake#3237](snakemake#3237))
([1dc0084](snakemake@1dc0084))
* use relpath for configfiles added to the source archive (thanks to
[@sposadac](https://github.com/sposadac) for the initial solution)
([snakemake#3240](snakemake#3240))
([bff3844](snakemake@bff3844))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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