diff --git a/snakemake/dag.py b/snakemake/dag.py index 8dc9973e2..bac2e27b0 100755 --- a/snakemake/dag.py +++ b/snakemake/dag.py @@ -1845,8 +1845,13 @@ async def finish(self, job, update_checkpoint_dependencies=True): self.create_conda_envs() potential_new_ready_jobs = True - for job in jobs: - await self.handle_temp(job) + if not any(self.checkpoint_jobs): + # While there are still checkpoint jobs, we cannot safely delete + # temp files. + # TODO: we maybe could be more accurate and determine whether there is a + # checkpoint that depends on the temp file. + for job in jobs: + await self.handle_temp(job) return potential_new_ready_jobs diff --git a/tests/test_github_issue2732/Snakefile b/tests/test_github_issue2732/Snakefile new file mode 100644 index 000000000..cc0bdc1f7 --- /dev/null +++ b/tests/test_github_issue2732/Snakefile @@ -0,0 +1,38 @@ +rule a: + output: + temp("{name}.txt"), + shell: + "touch {output}" + +rule a1: + input: + "{name}.txt", + output: + temp("{name}.a1.out"), + shell: + "touch {output}" + +rule b1: + input: + "A.txt", + output: + temp("A.b1.out"), + shell: + "touch {output}" + +checkpoint b2: + input: + "A.b1.out" + output: + "A.b2.out" + shell: + "echo A > {output}" + +def in_func1(w): + file = checkpoints.b2.get().output[0] + return open(file, "r").read().strip() + +rule all: + input: + lambda w: expand(rules.a1.output, name=in_func1(w)), + default_target: True \ No newline at end of file diff --git a/tests/test_github_issue2732/expected-results/A.b1.out b/tests/test_github_issue2732/expected-results/A.b1.out new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_github_issue2732/expected-results/A.b2.out b/tests/test_github_issue2732/expected-results/A.b2.out new file mode 100644 index 000000000..f70f10e4d --- /dev/null +++ b/tests/test_github_issue2732/expected-results/A.b2.out @@ -0,0 +1 @@ +A diff --git a/tests/tests.py b/tests/tests.py index d12ff05c4..370741798 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -2014,7 +2014,7 @@ def test_issue2685(): run(dpath("test_issue2685")) -@skip_on_windows +@skip_on_windows # OS agnostic def test_set_resources_complex(): run( dpath("test05"), @@ -2022,7 +2022,7 @@ def test_set_resources_complex(): ) -@skip_on_windows +@skip_on_windows # OS agnostic def test_set_resources_human_readable(): run( dpath("test05"), @@ -2030,16 +2030,21 @@ def test_set_resources_human_readable(): ) -@skip_on_windows +@skip_on_windows # OS agnostic def test_call_inner(): run(dpath("test_inner_call")) -@skip_on_windows +@skip_on_windows # OS agnostic def test_list_input_changes(): run(dpath("test01"), shellcmd="snakemake --list-input-changes", check_results=False) -@skip_on_windows +@skip_on_windows # OS agnostic def test_summary(): run(dpath("test01"), shellcmd="snakemake --summary", check_results=False) + + +@skip_on_windows # OS agnostic +def test_github_issue2732(): + run(dpath("test_github_issue2732"))