From b0079791718a390d1f920df15a405cf633314312 Mon Sep 17 00:00:00 2001 From: Elmar Pruesse Date: Mon, 21 Feb 2022 02:33:53 -0700 Subject: [PATCH] fix: Repair MREs from #823 (#1203) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add failing tests 823 * fix mistakes * black * Update tests from #823 MREs - Can't have the b.txt in first text be temp and expect it present, it will correctly be deleted. - Add third MRE which is targeting more of a log issue * Add error message printed if #823 is encountered, also exit 1 The main scheduler loop terminates if there are no more runnable jobs. This tests if there still are jobs that should be run, but that we cannot seem to get to. If so, print an error message, print the files affected, and exit 1. The latter is important so Snakemake can, as hotfix, be rerun in a loop until it's actually completed all tasks. * Fix checkpoint+temp leads to incomplete run issue The aggressive early deletion of temp files must ignore checkpoints. Other rules depend on a checkpoint only via the first output file of the checkpoint (flagged string) as a stub. All other outputs marked as temp would be deleted (and have been before this patch). Since those files are missing, the dependent rules will never be runnable and the workflow ends before all targets have been built. * Don't break untiljobs * fix typo Co-authored-by: Maarten-vd-Sande Co-authored-by: Johannes Köster Co-authored-by: Johannes Köster --- snakemake/scheduler.py | 19 ++++++++++++++++++- tests/test_issue823_3/Snakefile | 9 +++++++++ tests/test_issue823_3/expected-results/a.txt | 0 tests/tests.py | 5 +++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/test_issue823_3/Snakefile create mode 100644 tests/test_issue823_3/expected-results/a.txt diff --git a/snakemake/scheduler.py b/snakemake/scheduler.py index c26f39e9a..1b3ac8669 100644 --- a/snakemake/scheduler.py +++ b/snakemake/scheduler.py @@ -43,6 +43,11 @@ def cumsum(iterable, zero=[0]): "Exiting because a job execution failed. " "Look above for error message" ) +_ERROR_MSG_ISSUE_823 = ( + "BUG: Out of jobs ready to be started, but not all files built yet." + " Please check https://github.com/snakemake/snakemake/issues/823 for more information." +) + class DummyRateLimiter(ContextDecorator): def __enter__(self): @@ -470,11 +475,23 @@ def schedule(self): return False continue - # normal shutdown because all jobs have been finished + # all runnable jobs have finished, normal shutdown if not needrun and (not running or self.workflow.immediate_submit): self._executor.shutdown() if errors: logger.error(_ERROR_MSG_FINAL) + # we still have unfinished jobs. this is not good. direct + # user to github issue + if self.remaining_jobs: + logger.error(_ERROR_MSG_ISSUE_823) + logger.error( + "Remaining jobs:\n" + + "\n".join( + " - " + str(job) + ": " + ", ".join(job.output) + for job in self.remaining_jobs + ) + ) + return False return not errors # continue if no new job needs to be executed diff --git a/tests/test_issue823_3/Snakefile b/tests/test_issue823_3/Snakefile new file mode 100644 index 000000000..67f777b51 --- /dev/null +++ b/tests/test_issue823_3/Snakefile @@ -0,0 +1,9 @@ +rule all: + input: + "a.txt" + +checkpoint a: + output: + "a.txt" + shell: + "touch {output}" diff --git a/tests/test_issue823_3/expected-results/a.txt b/tests/test_issue823_3/expected-results/a.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tests/tests.py b/tests/tests.py index bfa2503fa..547889599 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -887,6 +887,11 @@ def test_issue823_2(): run(dpath("test_issue823_2")) +@skip_on_windows +def test_issue823_3(): + run(dpath("test_issue823_3")) + + @skip_on_windows def test_pathlib(): run(dpath("test_pathlib"))