Fix #2845: emit certified populace-us URI in Reproduce-in-Python snippets#2846
Fix #2845: emit certified populace-us URI in Reproduce-in-Python snippets#2846MaxGhenis wants to merge 1 commit into
Conversation
The code generator hardcoded archived policyengine-us-data HF URIs (enhanced_cps_2024.h5, pooled_3_year_cps_2023.h5) instead of the populace-us dataset that policyengine.py now resolves as its certified default. Users copying "Reproduce in Python" snippets from policyengine.org were pointed at a deprecated, uncertified dataset. Fixes #2845 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Updates the “Reproduce in Python” snippet generator to emit the certified populace-us Hugging Face URI (pinned to the certified revision) instead of the archived policyengine-us-data URIs, aligning snippets with what policyengine.py resolves as the default US microdata.
Changes:
- Centralized the certified US default dataset URI as
POPULACE_US_DEFAULT_DATASET_URIand reused it forenhanced_cpsmapping. - Updated the state-level fallback dataset in
getImplementationCode()to use the certified populace-us URI. - Updated Jest expectations to assert against the shared constant rather than hardcoded strings.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/data/reformDefinitionCode.js | Replaces the US state fallback dataset URI with the shared certified populace-us constant. |
| src/data/countries.js | Adds POPULACE_US_DEFAULT_DATASET_URI and routes DEFAULT_DATASETS.enhanced_cps through it. |
| src/tests/data/reformDefinitionCode.test.js | Updates tests to assert the new certified URI via the shared constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // The certified populace-us dataset that policyengine.py resolves as its | ||
| // default US microdata (see src/policyengine/data/bundle/manifest.json's | ||
| // data_releases.us.default_dataset_uri in PolicyEngine/policyengine.py). | ||
| // This pins the certified revision so "Reproduce in Python" snippets stay | ||
| // byte-reproducible; bump the revision suffix when populace-us is | ||
| // re-certified (see PolicyEngine/populace#204 for the migration history). |
|
Closing as part of the policyengine-app (v1) wind-down. policyengine.org is now served by That PR ports the same pattern (certified The underlying tracking issue #2845 will be closed pointing at the v2 fix. |
Two markdown deliverables for the policyengine-app (v1) archival, for the lead to review before any bulk action: - docs/wind-down/issue-triage.md: all 394 open issues classified (8 keep-refile, 5 keep-has-v2-equiv, 377 close-stale, 4 close-duplicate), with v2-equivalent cross-references and a full ascending verdict index. - docs/wind-down/pr-closure-drafts.md: ready-to-post closure notes for the 23 open PRs left for the lead (15 community + 8 other), with per-PR re-land assessments. (The 6 Dependabot PRs and my #2846 were already closed with courteous notes as part of the sweep.) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Add deprecation notice to README policyengine.org is now served by policyengine-app-v2 (Next.js); this Create React App front end no longer powers the live site and is being archived. Add a prominent banner at the top of the README pointing to app-v2 for the live app and for new issues/PRs, and to legacy.policyengine.org for the previous version. Existing README content is retained below for historical reference. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Add wind-down triage docs for the lead's review gate Two markdown deliverables for the policyengine-app (v1) archival, for the lead to review before any bulk action: - docs/wind-down/issue-triage.md: all 394 open issues classified (8 keep-refile, 5 keep-has-v2-equiv, 377 close-stale, 4 close-duplicate), with v2-equivalent cross-references and a full ascending verdict index. - docs/wind-down/pr-closure-drafts.md: ready-to-post closure notes for the 23 open PRs left for the lead (15 community + 8 other), with per-PR re-land assessments. (The 6 Dependabot PRs and my #2846 were already closed with courteous notes as part of the sweep.) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Summary
Fixes #2845. The live "Reproduce in Python" code generator (
src/data/reformDefinitionCode.js) hardcoded archivedhf://policyengine/policyengine-us-data/...Hugging Face URIs for US state-level andenhanced_cpsruns.policyengine-us-datais deprecated/archived — users copying these snippets from policyengine.org were pointed at an uncertified dataset thatpolicyengine.pyno longer resolves as its default.This swaps both hardcoded URIs for the certified
populace-usdataset thatpolicyengine.py's bundle manifest (src/policyengine/data/bundle/manifest.json,data_releases.us.default_dataset_uri) actually resolves today, and centralizes the URI as a single named export (POPULACE_US_DEFAULT_DATASET_URIinsrc/data/countries.js) so both call sites and the test suite share one source of truth.Found during the populace#204 artifact-replacement audit, which named
src/data/reformDefinitionCode.js:188andsrc/data/countries.js:61explicitly as live production hardcodes. The prior tracking issue (#2828) was closed as "moved to policyengine-app-v2" without a v1 fix ever being filed — that's what #2845 re-opens for this repo.Before / after
US state-level policy run (e.g. California), previously fell back to a pooled-CPS file that no longer represents the certified default:
National run with the "enhanced_cps" dataset selected:
URI-form decision: pinned to the certified revision, not tracking
mainThe replacement URI includes an
@populace-us-2024-sparse-l0-refit-57k-71a0887-national-only-20260701revision suffix rather than a barehf://policyengine/populace-us/populace_us_2024.h5. This is a deliberate choice, not an oversight:policyengine.pyitself resolves.CountryReleaseManifest.default_dataset_uri(src/policyengine/provenance/manifest.py) returnscertified_data_artifact.uriwhen the certified artifact matches the default dataset — and that URI is always the pinned@revisionform, verified against bothpolicyengine.py's checked-inmanifest.jsonand its own test suite (tests/test_us_regions.py,tests/test_models.py), which assert the full pinned string as the resolved value. There is no "unpinned/latest-tracking" form anywhere inpolicyengine.py's actual resolution path — pinning is what "the populace default that policyengine.py actually resolves" means concretely.PolicyReproducibility.jsx/HouseholdReproducibility.jsxrender this snippet under the heading "Reproduce these results," generated fresh on every page view for the results the user is looking at right now. A revision-pinned URI gives byte-identical reproduction of that specific dataset; a bare/tracking URI would silently resolve to whatever HF'smainbranch holds by the time the user runs the copied snippet, which could be a different (or not-yet-existing) file.enhanced_cps_2024.h5,pooled_3_year_cps_2023.h5), bumped manually as datasets changed — this PR keeps that same pattern, just pointing at the current certified value. A follow-up PR bumpingPOPULACE_US_DEFAULT_DATASET_URIwhen populace-us is re-certified to a new revision is the same maintenance cost as before, now centralized in one constant instead of duplicated across two files.One discrepancy surfaced during this investigation, flagged for visibility but out of scope here:
policyengine-us's ownsystem.py:49DEFAULT_DATASETconstant is still pinned to an older revision (c86a631-6e1bcd0271a5-20260619T002242Z, 2026-06-19) thanpolicyengine.py's bundle manifest (sparse-l0-refit-57k-71a0887-national-only-20260701, 2026-07-01) — both point at the same repo/file, just different certified builds. This PR follows thepolicyengine.pymanifest value since that's the client this app's generated code targets.Scope
Swept all of
src/(excludingsrc/posts/, which is historical blog content covered separately by #2659) for otherpolicyengine-us-datareferences. Found and fixed exactly two call sites, both now covered by the shared constant:src/data/reformDefinitionCode.js—getImplementationCode()'s US-state fallback branchsrc/data/countries.js—DEFAULT_DATASETS.enhanced_cpsNo other live code path references the archived repo after this change (verified with a repo-wide grep).
Changelog
This repo's
changelog_entry.yamlis no longer wired into any CI workflow or Makefile target (checked.github/workflows/,Makefile) — the last several merged PRs (#2842, #2841, #2821, #2820, #2817) didn't touch it either, and the file at HEAD still carries a stale entry from an already-merged, already-released PR. Following current repo practice, this PR does not add a changelog entry.Test plan
--max-warnings 0+ Prettier check, matching CI) — exit 0, zero warnings repo-widesrc/__tests__/data/reformDefinitionCode.test.jswith--verbose— 23/23 tests passed, exit 0, including the 3 tests updated to assert the new URIdatatest paths — 24/24 tests passed acrosscountries.test.js+reformDefinitionCode.test.js, exit 0policyengine-us-datareferences outsidesrc/posts/🤖 Generated with Claude Code