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 snakemake.params to track config updates #823

Merged
merged 10 commits into from Aug 28, 2023

Conversation

virio-andreyana
Copy link
Contributor

@virio-andreyana virio-andreyana commented Aug 6, 2023

Closes #767

Changes proposed in this Pull Request

Use the params: section in rule definition to keep track of changed settings in config.yaml.

https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#non-file-parameters-for-rules

The goal is that rules for which parameters have changed rerun automatically.

This can currently be done with:

https://snakemake.readthedocs.io/en/stable/project_info/faq.html#how-do-i-trigger-re-runs-for-rules-with-updated-code-or-parameters

snakemake -n -R `snakemake --list-params-changes`

or

snakemake -R $(snakemake --list-params-changes)

This will be even more convenient, once this snakemake PR is released:

snakemake/snakemake#1107

snakemake --rerun-params-changed

or

snakemake --rerun-changed

(which would also include code changes)

It seems to work very nicely to pass lists/dicts as params, which would help us keep config "blocks".

This PR is not complete yet, but a proof-of-concept for a selection of config settings. We can discuss from here and complete later.

Checklist

  • I consent to the release of this PR's code under the AGPLv3 license and non-code contributions under CC0-1.0 and CC-BY-4.0.
  • 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 doc/requirements.txt.
  • Changes in configuration options are added in all of config.default.yaml and config.tutorial.yaml.
  • Add a test config or line additions to test/ (note tests are changing the config.tutorial.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, including reference to the requested PR.

@virio-andreyana virio-andreyana changed the title Add param Add snakemake.params to track config updates Aug 6, 2023
@davide-f
Copy link
Member

davide-f commented Aug 7, 2023

Cool @virio-andreyana ! Thanks for taking care of this issue! :D
Let us know when you need support or a review :)

@virio-andreyana virio-andreyana marked this pull request as ready for review August 8, 2023 13:17
@virio-andreyana
Copy link
Contributor Author

You're welcome @davide-f. The addition of the params is almost complete. What's still a bit missing is for the script solve_network.py. This is because it has the function extra_functionalities where the config is defined by the by n.config. But honestly, if any changes happen before this rule, solve_network will always be run.

Other than that, are there any suggestion and naming convention I should follow?

Copy link
Member

@davide-f davide-f left a comment

Choose a reason for hiding this comment

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

Really amazing job! :D
This review also let me realize that on a coding perspective some rulues may be improved to trop some params, but that's not for this PR.
Maybe good to open an issue on that.

Added few comments on it :)
Merging this PR is likely to lead to some merge conflicts, so its merging is going to be discussed during the next meetings too. But it is a feature we want! :D

Snakefile Outdated Show resolved Hide resolved
Snakefile Outdated Show resolved Hide resolved
Snakefile Outdated Show resolved Hide resolved
Snakefile Show resolved Hide resolved
scripts/add_electricity.py Outdated Show resolved Hide resolved
@davide-f davide-f mentioned this pull request Aug 11, 2023
@davide-f
Copy link
Member

Awesome job @virio-andreyana !
I think this PR is ready to go :) I would like to discuss on it with the others on thursday to avoid git conflicts and can be merged soon after that :)
Great!

@davide-f davide-f added this to the v0.2.3 milestone Aug 15, 2023
@davide-f
Copy link
Member

davide-f commented Aug 22, 2023

@virio-andreyana FYI, as #824 and #822 are merged, this PR follows along with the new release v0.2.3 including you as contributor :)
I can take care of the minor conflicts if existing, if major I may ask little support.
Many thanks @virio-andreyana !!!

@davide-f
Copy link
Member

davide-f commented Aug 28, 2023

Great @virio-andreyana ! The PR is ready to merge :)
Many thanks for the contribution, you are now officially a contributor :D Very useful contribution and looking forward to the next PR that is in the cooking :D

@davide-f davide-f merged commit 7c6d32b into pypsa-meets-earth:main Aug 28, 2023
4 checks passed
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.

use of snakemake.params to track config updates
2 participants