-
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
Allow attribute filtering in nomenclature.yaml for importing definitions form external repo #326
Comments
This looks great, but I'm wondering about two issues.
See a more explicit definitions:
variable:
repository:
common-definitions:
filters:
- name: Primary Energy*
tier: 1
- name: Final Energy* to get all final-energy variables and only primary-energy-variables at tier 1. |
Good points. Regarding your first point, you're right, it does look better to me as well. The reason I did intentionally opt against it in my proposed structure is that this would require bigger changes to the code. Nothing crazy but more difficult to implement than just adding another attribute at the repository level. I do agree though that it's nicer that way. For your second point, I'd take your example exactly the way you suggested. Meaning that within a filter entry it's an AND and between filters it's an OR. One point that's remaining is to cover is if we allow lists as filter values, and if so how they're evaluated: definitions:
variable:
repository:
common-definitions:
filters:
- name: Primary Energy*
tier: [1, 2] i.e. would the above translate to: "Everything that starts with Primary Energy* and has the tier attribute [1, 2]" or "Everything that starts with Primary Energy* and has the tier attribute 1 or 2". In this example only the latter makes sense but there might be attributes where we actually want to match a list. Alternatively, we could also only allow for single values, so if you wanted to achieve the above you'd have to use: definitions:
variable:
repository:
common-definitions:
filters:
- name: Primary Energy*
tier: 1
- name: Primary Energy*
tier: 2 in this example we could even allow for list values but then they have to match exactly. |
I guess we will quickly run into a use case like "give me primary energy, final energy, CO2 emissions, GDP, ..." from an upstream-repo, so repeating the "name" attribute many time will be tedious. So I would say the following logic makes most sense:
|
Sounds good, that should cover what we need. I cannot think of a use case where we'd need to explicitly match for a list anyway. |
When importing from an external repository we should be able to filter by attributes. This way we don't import the whole definition if it's not needed.
The first three use cases that come to mind are:
tier
for variablesThe question would be how to integrate this into the existing
nomenclature.yaml
structure.I've tried a few things now and this is my current favorite:
This would import all R5 regions from common-definitions and all variables starting with
Final Energy*
.The above format would also allow for more complex filtering such as:
here we have multiple filters for the variable dimension:
Final Energy*
Would love to hear your thoughts @danielhuppmann, @dc-almeida.
The text was updated successfully, but these errors were encountered: