-
Notifications
You must be signed in to change notification settings - Fork 454
fix: two crashes when building cutouts and using years outside the input data - #2283
Open
18blasim wants to merge 3 commits into
Open
fix: two crashes when building cutouts and using years outside the input data #228318blasim wants to merge 3 commits into
18blasim wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
Fixes #2156, which I reported in April.
Both issues surfaced when running the workflow with a locally built cutout for a historical weather year (1990). They are independent, so feel free to ask me to split this PR.
dataset_version() in rules/common.smk builds the field with Path(...).as_posix(), so CUTOUT_DATASET["folder"] is a string. The build rule joins the filename with the / operator, which raises TypeError: unsupported operand type(s) for /: 'str' and 'str'. rules/retrieve.smk already uses + for the same variable, so this is an inconsistency between the two files. Only affects source: build, which is why it is easy to miss when using the pre-built cutouts.
The code selects the snapshot year from a conventional input file and falls back to the last column, with the comment "take last column if year selection fails". However df[year] raises KeyError for a year that is not among the columns, and KeyError is not caught, so the fallback never triggers for the most common failure case.
This is not limited to unusual years: data/nuclear_p_max_pu.csv covers 2009 to 2024 but skips 2014, so even a year inside the nominal range aborts the run.
Adding KeyError to the existing except clause restores the documented behaviour.