-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
✨ Simplify GBD metadata with Jinja macros #3917
Conversation
Quick links (staging server):
Login: chart-diff: ✅No charts for review.data-diff: ✅ No differences foundLegend: +New ~Modified -Removed =Identical Details
Hint: Run this locally with etl diff REMOTE data/ --include yourdataset --verbose --snippet Automatically updated datasets matching weekly_wildfires|excess_mortality|covid|fluid|flunet|country_profile|garden/ihme_gbd/2019/gbd_risk are not included Edited: 2025-02-02 08:18:37 UTC |
fcc4d1a
to
1b5d59e
Compare
we should make sure that this doesn't lead to the behavior here. |
9af4cc3
to
1775790
Compare
I just realized in this data page that there is a mysterious whitespace:
![]() I am not sure what is the source for this; I tried looking into Unsure if related, but when using <% if ... %>
...
<%- elif ... %>
...
<%- else %>
...
<%- endif %> |
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.
Looks awesome, thanks Mojmir! There is a still a whitespace issue with HIV/AIDs that Lucas noticed, which I've had a go at getting rid of in a separate PR. but I think it requires a sacrifice to the Jinja gods 😅
Strangely it looks okay in the playground notebook, but will have more of a play tomorrow.
Motivation
GBD metadata is currently non-manageable. Even simple fix such as adding exception to
cause
ballooned into this monster. We need a way how to DRY it.Solution
Add support for
shared.meta.yml
where user can adddefinitions:
ormacros:
and use them across other YAML files.Use macros instead of raw jinja. Macros are very similar to python functions and can be parametrized, which allowed me to DRY a lot of duplicated code. I used o1 and o3 heavily when refactoring & DRYing those functions. There's certainly more space for a cleanup, but I didn't have enough time to polish it.
Alternatives
At first, I thought that registering custom python functions would be the best solution, but it was overly complex and didn't really solve the problem. One of the issues was that python functions would have to be defined in the grapher step, while YAML metadata would live in a garden step.
GBD metadata
Besides DRYing metadata, I fixed a couple of whitespace issues.