Skip to content

Add standard logging of config values #18

@joverlee521

Description

@joverlee521

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
  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)
  3. 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)}")
  4. 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)}")
  5. Always dumping the final, fully-expanded, config-as-loaded to an output file, e.g. results/config.yaml. (comment)

TODOs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions