Skip to content

Make default_target configurable#2218

Open
brynpickering wants to merge 1 commit into
PyPSA:masterfrom
open-energy-transition:feat/custom-default-target
Open

Make default_target configurable#2218
brynpickering wants to merge 1 commit into
PyPSA:masterfrom
open-energy-transition:feat/custom-default-target

Conversation

@brynpickering

Copy link
Copy Markdown
Contributor

This allows users to leverage the rulegraph and filegraph rules in their soft forks and to point pixi run snakemake to their own "all"-style rule without needing to delete default_target: True from the existing all rule.

Technically, it also allows a user to also have different default targets per run, so they can call pixi run snakemake --configfile config/config.<run-with-different-target>.yaml and it will switch out the default target for that run without the user needing to specify the target in the CLI call. Useful for tests, perhaps?

Checklist

Required:

  • Changes are tested locally and behave as expected.
  • Code and workflow changes are documented.
  • A release note entry is added to doc/release_notes.md.

If applicable:

  • Changes in configuration options are reflected in scripts/lib/validation.
  • For new data sources or versions, these instructions have been followed.
  • New rules are documented in the appropriate doc/*.md files.

@euronion

Copy link
Copy Markdown
Contributor

Interesting feature! So I can also reference rules that are only included later from external .smk files, and there are no checks performed on whether the rule exists?
What's the error pattern if the rule doesn't exist?

@brynpickering

Copy link
Copy Markdown
Contributor Author

Interesting feature! So I can also reference rules that are only included later from external .smk files, and there are no checks performed on whether the rule exists?
What's the error pattern if the rule doesn't exist?

Asking the right questions. If I put in a rule that doesn't exist, I get a MissingRuleException:

MissingRuleException:
No rule to produce foobar (if you use input functions make sure that they don't raise unexpected exceptions).

I could add a custom check at the end of the top-level Snakefile to create a more specific error message but I think this might be overkill...

@euronion

Copy link
Copy Markdown
Contributor

A different error message would certainly be more user friendly, albeit maybe overengineered?

Quick and simple: Document the error message that would come out if one uses a rule that does not exist.
More advanced: Your suggestions with a custom check at the end of the Snakefile
Best: Validation with the config file validation (would need to read the Snakefile and parse).

@fneum fneum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice mini-feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants