From b3c4e687c87c75075393cef842b129dcec70e7f6 Mon Sep 17 00:00:00 2001 From: Don Freed Date: Mon, 11 Oct 2021 04:12:04 -0700 Subject: [PATCH] feat: Add more informative errors when evaluation of `--default-resources` fails (#1192) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- snakemake/resources.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/snakemake/resources.py b/snakemake/resources.py index 0d80545c8..242d6e129 100644 --- a/snakemake/resources.py +++ b/snakemake/resources.py @@ -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