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

fix: do not remove existing temp files in case of dryrun #1543

Merged
merged 1 commit into from Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions snakemake/dag.py
Expand Up @@ -642,8 +642,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 @@ -1575,3 +1575,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)