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

Constrain Snakefile rule build_renewable_profiles with wildcard_constraint #333

Merged
merged 4 commits into from Mar 24, 2022

Conversation

euronion
Copy link
Contributor

  • Introduce a wildcard_constraint to limit build_renewable_profiles to certain technologies.
  • Remove potential ambuitiy for resources/profile_hydro.nc
  • Remove optional inclusion of build_hydro_profile: Unnecessary, as rule is only executed, if add_electricity wants it.

Side effect:

  • Easier to understand snakemake errors when trying to run with an unsupported technology :
# before PR
$ snakemake -call -n resources/profile_hello.nc
Building DAG of jobs...
InputFunctionException in line 185 of .../pypsa-eur/Snakefile:
Error:
  KeyError: 'hello'
Wildcards:
  technology=hello
Traceback:
  File ".../Snakefile", line 191, in <lambda>

# after PR
$ snakemake -call -n resources/profile_hello.nc
Building DAG of jobs...
MissingRuleException:
No rule to produce resources/profile_hello.nc (if you use input functions make sure that they don't raise unexpected exceptions).

Checklist

  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Newly introduced dependencies are added to envs/environment.yaml and envs/environment.docs.yaml.
  • Changes in configuration options are added in all of config.default.yaml, config.tutorial.yaml, and test/config.test1.yaml.
  • Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes.

@euronion
Copy link
Contributor Author

Ok, CI failed because the test config.yaml did not contain the hydro key. The new push should fix that.

The aim was to make not the rule optional, but present a more deterministic set of rules which is not based on the existance of config values.

Output in case build_hydro_profiles is called now without an hydro key being defined in the config:

$ snakemake -call -n resources/profile_hydro.nc
Building DAG of jobs...
MissingInputException in line 208 of .../Snakefile:
Missing input files for rule build_hydro_profile:
config['renewable']['hydro']['cutout'] not configured

@fneum
Copy link
Member

fneum commented Mar 18, 2022

@euronion
Copy link
Contributor Author

Rule order makes sense IMHO if the rules are ambigious. In our case the rules don't need to be ambigious, so I'd prefer to use that route rather than keeping them ambigiuous.

Snakefile Outdated Show resolved Hide resolved
Snakefile Show resolved Hide resolved
@fneum fneum merged commit 8f74d1e into master Mar 24, 2022
@fneum fneum deleted the fix/snakefile-renewable-wildcards branch March 24, 2022 13:20
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.

None yet

2 participants