From 84d1f6451b12352eba5a8bfefcfcce8b2d98c5aa Mon Sep 17 00:00:00 2001 From: Don Freed Date: Thu, 21 Oct 2021 05:29:56 -0700 Subject: [PATCH] fix: run dependencies with non-existent ancient files before the consuming job (#1202) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #946 Co-authored-by: Johannes Köster --- snakemake/dag.py | 2 +- tests/test_ancient_dag/Snakefile | 39 +++++++++++++++++++ .../expected-results/.gitkeep | 0 tests/tests.py | 4 ++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/test_ancient_dag/Snakefile create mode 100644 tests/test_ancient_dag/expected-results/.gitkeep diff --git a/snakemake/dag.py b/snakemake/dag.py index f6ef9b69d..e60eaa7c0 100755 --- a/snakemake/dag.py +++ b/snakemake/dag.py @@ -1040,7 +1040,7 @@ def update_needrun(job): if job_ not in visited: # TODO may it happen that order determines whether # _n_until_ready is incremented for this job? - if all(f.is_ancient for f in files): + if all(f.is_ancient and f.exists for f in files): # No other reason to run job_. # Since all files are ancient, we do not trigger it. continue diff --git a/tests/test_ancient_dag/Snakefile b/tests/test_ancient_dag/Snakefile new file mode 100644 index 000000000..b74c6872d --- /dev/null +++ b/tests/test_ancient_dag/Snakefile @@ -0,0 +1,39 @@ +shell.executable("bash") + +rule all: + input: + "d.out", + +rule A: + output: + "a.out", + shell: + "echo 'text' > {output}" + +rule B: + input: + ancient("a.out"), + output: + "b_{i}.out", + shell: + "cat {input} > {output}" + +# rule C is required for #946 +# use `range(20)` so test will pass in < 5% of cases where issue is present +rule C: + input: + expand("b_{i}.out", i=list(range(20))), + output: + "c.out", + shell: + "cat {input} > {output}" + +# For #946, 'a.out' is required as input, but does not need to be `ancient()` +rule D: + input: + "a.out", + "c.out", + output: + "d.out", + shell: + "cat {input} > {output}" diff --git a/tests/test_ancient_dag/expected-results/.gitkeep b/tests/test_ancient_dag/expected-results/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/tests/tests.py b/tests/tests.py index 9511a63d2..0223c0bc2 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1320,3 +1320,7 @@ def test_github_issue1158(): dpath("test_github_issue1158"), cluster="./qsub.py", ) + + +def test_ancient_dag(): + run(dpath("test_ancient_dag"))