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 .render method to render Jinja templates #4083

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Marigold
Copy link
Collaborator

@Marigold Marigold commented Mar 7, 2025

Replace function for rendering metadata with Jinja templates

import etl.grapher.helpers as gh
gh.render_variable_meta(tb.emissions.m, dim_dict={'pollutant': 'CO', 'sector': 'Transport'})

by

tb.emissions.m.render({'pollutant': 'CO', 'sector': 'Transport'})

As part of this, I also did:

  • Move Jinja functions to owid-catalog
  • Refactor dimension rendering in grapher:// step

The other function render_yaml_file for rendering Jinja from YAML file will be also moved in the future (to the new "YAMLMeta" object).

One disadvantage of .render(...) is that you need to build the garden dataset & load it to render it. It's often easier to work solely with the YAML file and use render_yaml_file.

@Marigold Marigold marked this pull request as ready for review March 7, 2025 10:21
@owidbot
Copy link
Contributor

owidbot commented Mar 7, 2025

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-render-jinja

chart-diff: ✅ No charts for review.
data-diff: ✅ No differences found
Legend: +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-03-07 10:22:15 UTC
Execution time: 16.57 seconds

@Marigold Marigold requested a review from pabloarosado March 7, 2025 10:33
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.

2 participants