Skip to content
Permalink
Browse files
fix: proper error message when defining cache eligibility for rules w…
…ith multiple output files and no multiext declaration. (#1357)

* dbg message for cache fetching

* dbg

* handle invalid multi output rules marked as cacheable

* cleanup

* fmt

* add testcase
  • Loading branch information
johanneskoester committed Jan 28, 2022
1 parent 6c505c2 commit 47b5096ebbdd3d94a9c99b443064b1b0de389c64
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
@@ -47,6 +47,9 @@ def get_outputfiles(self, job: Job):
)
yield from ((f, f[prefix_len:]) for f in job.output)
else:
assert (
len(job.output) == 1
), "bug: multiple output files in cacheable job but multiext not used for declaring them"
yield (job.output[0], "")

def raise_write_error(self, entry, exception=None):
@@ -95,6 +95,12 @@ def fetch(self, job: Job):
if not cachefile.exists():
self.raise_cache_miss_exception(job)

logger.debug(
"Output file {} exists as {} in the cache.".format(
outputfile, cachefile
)
)

self.check_readable(cachefile)
if cachefile.is_dir():
# For directories, create a new one and symlink each entry.
@@ -1541,6 +1541,14 @@ def decorate(ruleinfo):
rule.is_handover = True

if ruleinfo.cache is True:
if len(rule.output) > 1:
if not rule.output[0].is_multiext:
raise WorkflowError(
"Rule is marked for between workflow caching but has multiple output files. "
"This is only allowed if multiext() is used to declare them (see docs on between "
"workflow caching).",
rule=rule,
)
if not self.enable_cache:
logger.warning(
"Workflow defines that rule {} is eligible for caching between workflows "
@@ -0,0 +1,7 @@
rule a:
output:
"1.txt",
"2.txt",
cache: True
shell:
"touch {output}"
Empty file.
@@ -1397,3 +1397,7 @@ def test_modules_ruledeps_inheritance():
@skip_on_windows
def test_conda_named():
run(dpath("test_conda_named"), use_conda=True)


def test_cache_multioutput():
run(dpath("test_cache_multioutput"), shouldfail=True)

0 comments on commit 47b5096

Please sign in to comment.