Emit certified populace-us URI in US national Reproduce-in-Python snippets#1090
Merged
Merged
Conversation
…ppets
Ports policyengine-app v1 PR #2846 to app-v2. The "Reproduce in Python"
generator's US national branch (getDatasetUrl in reproducibilityCode.ts)
constructed hf://policyengine/policyengine-us-data/{name}_{year}.h5 for a
bare national dataset name. That repo is deprecated/archived and
policyengine.py no longer resolves it as the default, so a copied snippet
pointed users at an uncertified dataset.
- Centralize the certified URI as POPULACE_US_DEFAULT_DATASET_URI in
constants.ts (single source of truth), pinned to the revision the
bundle manifest resolves as data_releases.us.default_dataset_uri.
- getDatasetUrl now returns that URI for a bare US national name.
Fully-qualified URIs (the exact dataset a run used) still pass through
verbatim; default runs still omit dataset= entirely.
- Update the bare-name national test to assert the certified URI and the
absence of any policyengine-us-data reference.
Scope: the subnational (state/CD) and place fallbacks still reference
policyengine-us-data/{states,districts}/*.h5 by design, pending Populace
geo/place scoping — tracked in app-v2#1079. Documented at each call site;
deliberately NOT changed here to avoid colliding with that issue.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
5 tasks
MaxGhenis
marked this pull request as ready for review
July 6, 2026 18:44
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
Ports policyengine-app v1 PR #2846 to app-v2, part of the v1 → v2 wind-down.
The "Reproduce in Python" code generator's US national branch (
getDatasetUrlinapp/src/utils/reproducibilityCode.ts) constructedhf://policyengine/policyengine-us-data/{name}_{year}.h5for a bare national dataset name.policyengine-us-datais deprecated/archived, andpolicyengine.pyno longer resolves it as the certified default — so a user copying that snippet was pointed at an uncertified dataset.What v2 already got right (vs v1)
Unlike v1 — which hardcoded archived URIs on every branch — app-v2 already:
dataset=entirely for default runs (lettingpolicyengine.pyresolve the certified default), andgetScopedUsRegionImplementationCode).So the only residual leak was the bare non-default US national name path. This PR closes it.
Changes
app/src/constants.ts— addPOPULACE_US_DEFAULT_DATASET_URIas the single source of truth, pinned to the revision the bundle manifest resolves asdata_releases.us.default_dataset_uri(matching v1 #2846'sPOPULACE_US_DEFAULT_DATASET_URI).app/src/utils/reproducibilityCode.ts—getDatasetUrlreturns the certified URI for a bare US national name. Fully-qualified URIs (the exact dataset a run used) still pass through verbatim (given full dataset url then uses it verbatimunchanged), preserving reproducibility of a specific pinned run.app/src/tests/unit/utils/reproducibilityCode.test.ts— the bare-name national test now asserts the certified URI andnot.toContain('policyengine-us-data').changelog_entry.yaml— user-facing line.Scope: respects #1079 (no collision)
The subnational (state/CD) and place fallbacks still reference
policyengine-us-data/{states,districts}/*.h5by design — the certified Populace export does not yet carry place/geo scoping. That migration is tracked in #1079 ("Remove place fallback to split state H5s once Populace supports place scoping"). This PR:getSubnationalDatasetUrlorgetPlaceStateDatasetUrlbehavior, andLocal checks
reproducibilityCode.test.ts— 45 passsocietyWideCalculation.test.ts+SocietyWideReportOutput.test.tsx— 26 pass (verbatim/subnational URI assertions unaffected)typecheck— clean (website + calculator workspaces)eslint(changed files) — exit 0prettier --check— cleanNot observable in a browser preview
The changed function only renders inside a completed report-output "Reproduce in Python" panel (requires a live API report calculation with a non-default US national dataset selected); the code path is verified directly by the unit tests above.
🤖 Generated with Claude Code