Skip to content
Permalink
Browse files
feat: Add more informative errors when evaluation of `--default-resou…
…rces` fails (#1192)

* Add more informative errors when evalution of `--default-resources` fails

* Raise a `WorkflowError` if evaluation of `--default-resources` fails

* Trivial - re-run tests

Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
DonFreed and johanneskoester committed Oct 11, 2021
1 parent 0503a73 commit b3c4e687c87c75075393cef842b129dcec70e7f6
Showing 1 changed file with 15 additions and 0 deletions.
@@ -1,6 +1,8 @@
import re
import tempfile

from snakemake.exceptions import WorkflowError


class DefaultResources:
defaults = {
@@ -58,6 +60,19 @@ def callable(wildcards, input, attempt, threads, rulename):
# Triggers for string arguments like n1-standard-4
except NameError:
return val
except Exception as e:
if not (
isinstance(e, FileNotFoundError) and e.filename in input
):
# Missing input files are handled by the caller
raise WorkflowError(
"Failed to evaluate DefaultResources value "
"'{}'.\n"
" String arguments may need additional "
"quoting. Ex: --default-resources "
"\"tmpdir='/home/user/tmp'\".".format(val)
)
raise e
return value

return callable

0 comments on commit b3c4e68

Please sign in to comment.