Skip to content

Commit

Permalink
Merge pull request #1084 from nextstrain/fix/snakemake-7.32.1
Browse files Browse the repository at this point in the history
Fix snakemake rule existence checks
  • Loading branch information
jameshadfield committed Sep 20, 2023
2 parents 1d7e5db + 0279181 commit 183dd85
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion workflow/snakemake_rules/main_workflow.smk
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,14 @@ rule build_description:
with open(output.description, "w", encoding = "utf-8") as o:
o.write(template.safe_substitute(context))

def rule_exists(name):
# Some versions of Snakemake throw a WorkflowError even with the
# three-arg getattr(), so catch any error and assume non-existence.
try:
return bool(getattr(rules, name, None))
except:
return False

def get_auspice_config(w):
"""
Auspice configs are chosen via this heirarchy:
Expand All @@ -1403,7 +1411,7 @@ def get_auspice_config(w):
"""
if "auspice_config" in config["builds"].get(w.build_name, {}):
return config["builds"][w.build_name]["auspice_config"]
if "auspice_config" in rules.__dict__:
if rule_exists("auspice_config"):
return rules.auspice_config.output
return config["files"]["auspice_config"]

Expand Down

0 comments on commit 183dd85

Please sign in to comment.