Context
With many layers of Snakemake configs provided via default configs and/or CLI options (--configfile/--config), it is helpful to have a standard way of logging the config values used for a workflow run.
Consensus in discussions below is to go with option 5 of the possible solutions, which has been implemented by @victorlin in WNV with discussion in nextstrain/WNV@d4831ac.
Previously listed possible solutions
-
This is done in the ncov workflow with a dump_config rule. Users must specify the target with the same configs as their workflow run to see the config output.
-
We could print out the config with each workflow run using the onstart handler. However, Snakemake docs note that these handlers are not triggered during dry-runs.
onstart:
import yaml, sys
yaml.dump(config, sys.stdout, explicit_start = True, explicit_end = True)
-
We could print out the config with each workflow run using Snakemake's logger:
import yaml
from snakemake.logging import logger
# Use default configuration values. Override with Snakemake's --configfile/--config options.
configfile: "config/defaults.yaml"
logger.info(f"Config is:\n{yaml.dump(config, explicit_start = True, explicit_end = True)}")
-
If the config output is too noisy, we can make it a debug level log that will only output if users provide the --verbose flag.
import yaml
from snakemake.logging import logger
# Use default configuration values. Override with Snakemake's --configfile/--config options.
configfile: "config/defaults.yaml"
logger.debug(f"Config is:\n{yaml.dump(config, explicit_start = True, explicit_end = True)}")
-
Always dumping the final, fully-expanded, config-as-loaded to an output file, e.g. results/config.yaml. (comment)
TODOs
Context
With many layers of Snakemake configs provided via default configs and/or CLI options (
--configfile/--config), it is helpful to have a standard way of logging the config values used for a workflow run.Consensus in discussions below is to go with option 5 of the possible solutions, which has been implemented by @victorlin in WNV with discussion in nextstrain/WNV@d4831ac.
Previously listed possible solutions
This is done in the ncov workflow with a
dump_configrule. Users must specify the target with the same configs as their workflow run to see the config output.We could print out the config with each workflow run using the
onstarthandler. However, Snakemake docs note that these handlers are not triggered during dry-runs.We could print out the config with each workflow run using Snakemake's logger:
If the config output is too noisy, we can make it a debug level log that will only output if users provide the
--verboseflag.Always dumping the final, fully-expanded, config-as-loaded to an output file, e.g.
results/config.yaml. (comment)TODOs