Skip to content

Emit certified populace-us URI in US national Reproduce-in-Python snippets#1090

Merged
MaxGhenis merged 1 commit into
mainfrom
relanding/certified-populace-uri-reproduce
Jul 7, 2026
Merged

Emit certified populace-us URI in US national Reproduce-in-Python snippets#1090
MaxGhenis merged 1 commit into
mainfrom
relanding/certified-populace-uri-reproduce

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

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 (getDatasetUrl in app/src/utils/reproducibilityCode.ts) constructed hf://policyengine/policyengine-us-data/{name}_{year}.h5 for a bare national dataset name. policyengine-us-data is deprecated/archived, and policyengine.py no 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:

  • omits dataset= entirely for default runs (letting policyengine.py resolve the certified default), and
  • uses national Populace scoping for default state/CD runs (getScopedUsRegionImplementationCode).

So the only residual leak was the bare non-default US national name path. This PR closes it.

Changes

  • app/src/constants.ts — add POPULACE_US_DEFAULT_DATASET_URI as the single source of truth, pinned to the revision the bundle manifest resolves as data_releases.us.default_dataset_uri (matching v1 #2846's POPULACE_US_DEFAULT_DATASET_URI).
  • app/src/utils/reproducibilityCode.tsgetDatasetUrl returns 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 verbatim unchanged), 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 and not.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}/*.h5 by 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:

Local checks

  • reproducibilityCode.test.ts — 45 pass
  • societyWideCalculation.test.ts + SocietyWideReportOutput.test.tsx — 26 pass (verbatim/subnational URI assertions unaffected)
  • typecheck — clean (website + calculator workspaces)
  • eslint (changed files) — exit 0
  • prettier --check — clean

Not 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

…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>
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-app-v2 Ready Ready Preview, Comment Jul 6, 2026 6:32pm
policyengine-calculator Ready Ready Preview, Comment Jul 6, 2026 6:32pm
policyengine-calculator-next Ready Ready Preview, Comment Jul 6, 2026 6:32pm
policyengine-website Ready Ready Preview, Comment Jul 6, 2026 6:32pm

Request Review

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.

1 participant