-
Notifications
You must be signed in to change notification settings - Fork 14
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
Filter external repos #396
Filter external repos #396
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few suggestions inline.
As with my other review, I’d strongly advise against using fnmatch.
tests/data/nomenclature_configs/multiple_repos_for_mapping.yaml
Outdated
Show resolved
Hide resolved
0163e78
to
1bf3d5c
Compare
Quick clarifying question, one can only have one include and one exclude statement per repo-import, right? |
Correct. You can put multiple filters in both the include and exclude though. |
@danielhuppmann, I added a depth option now so you can match for the given level of variable depth. ...
include:
- name: Final Energy*
depth: [0, 1] which I think is plenty readable. |
@danielhuppmann, as discussed bilaterally, I changed the string pattern matching to use the pyam character escape and regex. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good, a few minor suggestions inline.
One larger question: if an imported model-mapping includes a common region that is filtered out in the region-codelist, the initialization of the region-processor will fail, right? (That's ok, just make sure to create a follow-up issue so that this can be tackled later).
tests/data/region_processing/external_repo_test/nomenclature.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: Daniel Huppmann <dh@dergelbesalon.at>
Looking at the code it looked fine to me but just to be sure I added a test in 60d77ce. I import all the mappings from common-definitions and only load the world region. It fails as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you!
Closes #326.
This PR adds the feature to filter external repositories using
include
andexclude
filters.Any number of filters combining any attributes can be defined, example:
For the variable section
in the example above we are including:
From this list we are then excluding all variables that match "Final Energy||".
This means that the final resulting list will contain no Final Energy variables with
three or more levels.
For the region section
we are taking only R5 and R10 regions.
Changes
One of the changes that I have made is that all repositories in the definition section need to have the
name
key-word.This would be a breaking change so all workflow repos that use external repositories would need to be updated.
I'd be happy to streamline it again so that just the name is allowed but for code simplicity I opted against that for now.