I am developing several snakemake
modules that will be imported by other projects, and I’d like to draw a distinction between configuration that users can alter (config/config.yaml
) and settings which should not be altered (resources/internal-settings.yaml
).
I would like to pass these as parameters to rules
similar to how it works with configuration files:
rule some_rule:
params:
protected = internal-settings["not_altered"],
unprotected = config["may_be_altered"]
Unfortunately, I have not been able to find a way to do this.
I’ve tried the following in a rules.smk
file outside of rules:
import yaml
from pathlib import Path
with open(Path(workflow.current_basedir) / "resources/internal-config.yaml", "r") as f:
internal_config = yaml.safe_load(f)
But it returns the following error:
TypeError in file https://raw.githubusercontent.com/hydro/modules/hydro/workflow/rules/hydro.smk, line 6:
expected str, bytes or os.PathLike object, not GithubFile
I’d expect snakemake
to just read the file relative to the module file in the GitHub repository, but it seems like this is not the case…
Ivan Ruiz Manuel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.