Repository navigation
Re-render an OG card when its title or summary changes - #1226
Merged
Merged
Conversation
Signed-off-by: minutechreview <141821420+minutechreview@users.noreply.github.com>
Contributor
|
@minutechreview is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
minutechreview
requested review from
ahmdkaml and
propcgamer20-png
as code owners
October 29, 2026 18:17
|
@yakew7 @Shreyash0712 @ahmdkaml @propcgamer20-png - new PR touching a path you own, please review. |
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.
Summary
generate_og_images.pynow stores a hash of each card's inputs inassets/og/card-inputs.jsonandassets/og-light/card-inputs.json, re-renders a card whose hash changed, andcheck_generated_files_current.pyfails when a stored hash is stale.Type
How it works:
card_inputs_hash(kicker, title, subtitle, theme)is the first 16 hex characters of a SHA-256 over those four values.card-inputs.json({slug: hash}, sorted). Keeping it next to the PNGs means the tests that pointTHEMES[...]["out_dir"]at a temp folder never touch the real files.main(), an existing PNG is skipped only while its stored hash matches. A changed title or summary, or a card with no stored hash, is re-rendered.--forcestill re-renders everything. The file is rewritten on every run with only the current cards, so removed explainers drop out.render_card_both_themes()called withoutstoredkeeps the old behaviour (skip any existing PNG), so the generate_og_images.py rewrites every existing OG image on a different machine #1144 test still holds.TEXT_GLOBS. Its fresh build already runs the generator, so a hash that no longer matches the inputs shows up asassets/og/card-inputs.json: content differs from a fresh regeneration, with the usual "runmake build-explainers" line.The two committed JSON files hold hashes of the current inputs for all 117 cards per theme, written without re-rendering any PNG. They assume the committed cards match today's titles and summaries. I can't confirm that pixel by pixel across platforms, so any card that was already stale before this PR stays as it is until it is edited or forced.
Proof, run on this branch:
assets/explainers-data.jsonand ran onlybuild_explainers.py. The check then failed with exactly the twocard-inputs.jsonlines. Runninggenerate_og_images.pyprintedWrote 2 of 234and changed onlyassets/og/popularity-bias.pngandassets/og-light/popularity-bias.pngplus the two JSON files. After that the check passed. I reverted the title afterwards.test_a_changed_title_re_renders_only_that_cards_two_pngs(onlysecond.pngis rewritten in each theme, only its hash changes, and a third run writes 0),test_card_inputs_hash_depends_on_every_input,test_text_globs_cover_the_og_card_input_hashes, andtest_main_flags_a_stale_og_card_input_hash. With the old generator the two generator tests fail. Without theTEXT_GLOBSlines the globs test fails.pytest tests/test_generate_images.py tests/test_check_generated_files_current.py tests/test_og_card_consistency.py: 30 passed, 1 skipped (slow).python3 scripts/check_generated_files_current.pypasses.ruff check,check_em_dash.py,check_broken_links.pyandcheck_issue_refs.pypass.The module docstrings, CHANGELOG (Unreleased, Added) and the README tree are updated.
Linked issue
Closes #1197