Skip to content

Commit

Permalink
fix: do not remove existing temp files in case of dryrun (#1543)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Mar 31, 2022
1 parent 8628a3e commit e820f97
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
7 changes: 5 additions & 2 deletions snakemake/dag.py
Expand Up @@ -639,8 +639,11 @@ def unneeded_files():
yield from filterfalse(partial(needed, job), tempfiles)

for f in unneeded_files():
logger.info("Removing temporary output file {}.".format(f))
f.remove(remove_non_empty_dir=True)
if self.dryrun:
logger.info(f"Would remove temporary output {f}")
else:
logger.info("Removing temporary output {}.".format(f))
f.remove(remove_non_empty_dir=True)

def handle_log(self, job, upload_remote=True):
for f in job.log:
Expand Down
20 changes: 20 additions & 0 deletions tests/test_github_issue1542/Snakefile
@@ -0,0 +1,20 @@
# Snakefile
rule all:
input:
"b.txt",


rule a:
output:
temp("a.txt"),
shell:
"touch a.txt"


rule b:
input:
"a.txt",
output:
"b.txt",
shell:
"touch b.txt"
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions tests/tests.py
Expand Up @@ -1580,3 +1580,7 @@ def test_pipe_depend():
@skip_on_windows # no pipe support on windows
def test_pipe_depend_target_file():
run(dpath("test_pipe_depend"), targets=["test.txt"], shouldfail=True)


def test_github_issue1542():
run(dpath("test_github_issue1542"), dryrun=True)

0 comments on commit e820f97

Please sign in to comment.