Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix snakemake rule existence checks #1084

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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