Skip to content

Commit

Permalink
Fix snakemake rule existence checks
Browse files Browse the repository at this point in the history
We use the existence of certain rules to control the DAG and the way
rules are stored internally changed in snakemake 7.32.1
<snakemake/snakemake@65c79a4>

This functionality is (probably?) only used for internal nextstrain builds
where we use the `auspice_config` rule to programmatically generate the
config.
  • Loading branch information
jameshadfield committed Sep 20, 2023
1 parent 1d7e5db commit 34839d1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion workflow/snakemake_rules/main_workflow.smk
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,15 @@ rule build_description:
with open(output.description, "w", encoding = "utf-8") as o:
o.write(template.safe_substitute(context))

def rule_exists(name):
# Snakemake 7.32.1 changed the way rules are stored internally
# https://github.com/snakemake/snakemake/commit/65c79a48f956077839bb5ab1ea8d60a5f0ddecab
from packaging import version # an explicit dependency of augur
if version.parse(snakemake.__version__) < version.parse('7.32.1'):
return name in rules.__dict__
else:
return name in rules.__dict__['_rules']

def get_auspice_config(w):
"""
Auspice configs are chosen via this heirarchy:
Expand All @@ -1403,7 +1412,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 34839d1

Please sign in to comment.