Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

Fix #2845: emit certified populace-us URI in Reproduce-in-Python snippets#2846

Closed
MaxGhenis wants to merge 1 commit into
mainfrom
fix-reproduce-populace-uri
Closed

Fix #2845: emit certified populace-us URI in Reproduce-in-Python snippets#2846
MaxGhenis wants to merge 1 commit into
mainfrom
fix-reproduce-populace-uri

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Summary

Fixes #2845. The live "Reproduce in Python" code generator (src/data/reformDefinitionCode.js) hardcoded archived hf://policyengine/policyengine-us-data/... Hugging Face URIs for US state-level and enhanced_cps runs. policyengine-us-data is deprecated/archived — users copying these snippets from policyengine.org were pointed at an uncertified dataset that policyengine.py no longer resolves as its default.

This swaps both hardcoded URIs for the certified populace-us dataset that policyengine.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_URI in src/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:188 and src/data/countries.js:61 explicitly 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:

- baseline = Microsimulation(dataset="hf://policyengine/policyengine-us-data/pooled_3_year_cps_2023.h5")
- reformed = Microsimulation(reform=reform, dataset="hf://policyengine/policyengine-us-data/pooled_3_year_cps_2023.h5")
+ baseline = Microsimulation(dataset="hf://policyengine/populace-us/populace_us_2024.h5@populace-us-2024-sparse-l0-refit-57k-71a0887-national-only-20260701")
+ reformed = Microsimulation(reform=reform, dataset="hf://policyengine/populace-us/populace_us_2024.h5@populace-us-2024-sparse-l0-refit-57k-71a0887-national-only-20260701")

National run with the "enhanced_cps" dataset selected:

- baseline = Microsimulation(dataset="hf://policyengine/policyengine-us-data/enhanced_cps_2024.h5")
+ baseline = Microsimulation(dataset="hf://policyengine/populace-us/populace_us_2024.h5@populace-us-2024-sparse-l0-refit-57k-71a0887-national-only-20260701")

URI-form decision: pinned to the certified revision, not tracking main

The replacement URI includes an @populace-us-2024-sparse-l0-refit-57k-71a0887-national-only-20260701 revision suffix rather than a bare hf://policyengine/populace-us/populace_us_2024.h5. This is a deliberate choice, not an oversight:

  • This is what policyengine.py itself resolves. CountryReleaseManifest.default_dataset_uri (src/policyengine/provenance/manifest.py) returns certified_data_artifact.uri when the certified artifact matches the default dataset — and that URI is always the pinned @revision form, verified against both policyengine.py's checked-in manifest.json and 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 in policyengine.py's actual resolution path — pinning is what "the populace default that policyengine.py actually resolves" means concretely.
  • The feature's own purpose demands it. PolicyReproducibility.jsx/HouseholdReproducibility.jsx render 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's main branch holds by the time the user runs the copied snippet, which could be a different (or not-yet-existing) file.
  • It matches the existing maintenance model. The code being replaced was already a hardcoded literal string (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 bumping POPULACE_US_DEFAULT_DATASET_URI when 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 own system.py:49 DEFAULT_DATASET constant is still pinned to an older revision (c86a631-6e1bcd0271a5-20260619T002242Z, 2026-06-19) than policyengine.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 the policyengine.py manifest value since that's the client this app's generated code targets.

Scope

Swept all of src/ (excluding src/posts/, which is historical blog content covered separately by #2659) for other policyengine-us-data references. Found and fixed exactly two call sites, both now covered by the shared constant:

  • src/data/reformDefinitionCode.jsgetImplementationCode()'s US-state fallback branch
  • src/data/countries.jsDEFAULT_DATASETS.enhanced_cps

No other live code path references the archived repo after this change (verified with a repo-wide grep).

Changelog

This repo's changelog_entry.yaml is 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

  • Lint with zero-warnings tolerance (ESLint --max-warnings 0 + Prettier check, matching CI) — exit 0, zero warnings repo-wide
  • Prettier write pass — all touched files already Prettier-compliant, no changes needed
  • Jest run of src/__tests__/data/reformDefinitionCode.test.js with --verbose — 23/23 tests passed, exit 0, including the 3 tests updated to assert the new URI
  • Jest run scoped to data test paths — 24/24 tests passed across countries.test.js + reformDefinitionCode.test.js, exit 0
  • Repo-wide grep confirms zero remaining policyengine-us-data references outside src/posts/

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings July 6, 2026 18:02
@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 Ready Ready Preview, Comment Jul 6, 2026 6:02pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_URI and reused it for enhanced_cps mapping.
  • 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.

Comment thread src/data/countries.js
Comment on lines +56 to +61
// 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).
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Closing as part of the policyengine-app (v1) wind-down.

policyengine.org is now served by policyengine-app-v2, so a fix landed here no longer reaches the live "Reproduce in Python" generator. I've re-implemented this fix on app-v2 instead, where the generator actually runs: PolicyEngine/policyengine-app-v2#1090.

That PR ports the same pattern (certified populace-us URI centralized as a shared constant, with tests) and additionally documents the subnational/place fallbacks that remain on policyengine-us-data pending Populace geo scoping (tracked in app-v2#1079).

The underlying tracking issue #2845 will be closed pointing at the v2 fix.

@MaxGhenis MaxGhenis closed this Jul 6, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Closed in policyengine-app Jul 6, 2026
MaxGhenis added a commit that referenced this pull request Jul 6, 2026
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>
MaxGhenis added a commit that referenced this pull request Jul 6, 2026
* 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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

Reproduce-in-Python still generates archived policyengine-us-data URIs; should emit the populace default

2 participants