Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: keep empty output and input dirs of --draft-notebook job
  • Loading branch information
johanneskoester committed Nov 29, 2021
1 parent e92ad48 commit f1181bd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
17 changes: 9 additions & 8 deletions snakemake/dag.py
Expand Up @@ -235,14 +235,15 @@ def update_jobids(self):
self._jobid[job] = len(self._jobid)

def cleanup_workdir(self):
for io_dir in set(
os.path.dirname(io_file)
for job in self.jobs
for io_file in chain(job.output, job.input)
if not os.path.exists(io_file)
):
if os.path.exists(io_dir) and not len(os.listdir(io_dir)):
os.removedirs(io_dir)
for job in self.jobs:
if not self.is_edit_notebook_job(job):
for io_dir, job in set(
os.path.dirname(io_file)
for io_file in chain(job.output, job.input)
if not os.path.exists(io_file)
):
if os.path.exists(io_dir) and not len(os.listdir(io_dir)):
os.removedirs(io_dir)

def cleanup(self):
self.job_cache.clear()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_jupyter_notebook_draft/Snakefile
Expand Up @@ -16,15 +16,15 @@ rule bar:
input:
infile = 'data.txt'
output:
outfile = 'result_intermediate.txt'
outfile = 'results/result_intermediate.txt'
conda:
'env.yaml'
notebook:
'Notebook.py.ipynb'

rule baz:
input:
infile = 'result_intermediate.txt'
infile = 'results/result_intermediate.txt'
output:
outfile = 'result_final.txt'
log:
Expand All @@ -37,7 +37,7 @@ rule baz:

rule wild:
input:
infile = 'result_intermediate.txt'
infile = 'results/result_intermediate.txt'
output:
outfile = '{what}.result_final.txt'
conda:
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion tests/tests.py
Expand Up @@ -1179,7 +1179,7 @@ def test_jupyter_notebook_draft():
dpath("test_jupyter_notebook_draft"),
use_conda=True,
edit_notebook=EditMode(draft_only=True),
targets=["result_intermediate.txt"],
targets=["results/result_intermediate.txt"],
check_md5=False,
)

Expand Down

0 comments on commit f1181bd

Please sign in to comment.