Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement rule-specific restart_times directive #949

Closed
wants to merge 1 commit into from

Conversation

kpj
Copy link
Contributor

@kpj kpj commented Apr 8, 2021

It is possible to call snakemake with --restart-times to automatically restart a rule if it crashes (and, e.g., increase resource requirements for the next run). So far this is only possible for all rules together and lacks specificity.

This PR introduces a rule-specific restart-times directive which allows to specify the number of restart attempts for a specific rule. It fixes #367.

A (silly) example could look like this:

rule all:
    input:
        "foo",


rule foo:
    output:
        touch("foo"),
    restart_times:
        1
    resources:
        mem_mb=lambda wildcards, attempt: 10 * attempt,
    run:
        print(resources.mem_mb)
        1 / 0

@sonarcloud
Copy link

sonarcloud bot commented Apr 8, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kpj
Copy link
Contributor Author

kpj commented Apr 8, 2021

At the moment there is an issue where rules which set the restart_times directive are executed too often because I do not understand how Snakemake's execution internals work.
The global variable set by the --restart-times commandline parameter is reset to 0 for rule executions and only retains its actual value the first time main() and thus exec(compile(..), ..) is executed.
I cannot figure out how this reset works and cannot apply it to the rule-specific restart times 😞

In addition, I'd like to make it possible to pass a function to restart_times which returns True if another attempt is supposed to be made and False otherwise.

I'd be happy to hear how one could solve this.

@kpj
Copy link
Contributor Author

kpj commented May 26, 2021

@johanneskoester Do you have any suggestion regarding the implementation? :-)

@kpj
Copy link
Contributor Author

kpj commented Jul 17, 2022

This is now reasonably resolved by #1649.

@kpj kpj closed this Jul 17, 2022
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.

Allow --restart-times to specify rule name to be applied to
1 participant