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

Add standard logging of config values #18

Open
joverlee521 opened this issue Nov 27, 2023 · 2 comments
Open

Add standard logging of config values #18

joverlee521 opened this issue Nov 27, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@joverlee521
Copy link
Contributor

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.

Possible solutions

  1. 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.

  2. 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)
  1. 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)}")
  1. 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)}")
@joverlee521 joverlee521 added the enhancement New feature or request label Nov 27, 2023
@tsibley
Copy link
Member

tsibley commented Jan 10, 2024

Option 3 is enticing because it means the actual config in use is always in build logs, so when something unexpectedly goes wrong you can inspect the config (without having to reconstruct it in a separate subsequent run).

@jameshadfield
Copy link
Member

Option 3 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants