Repository navigation
Upgrade .py to 6.7.5 and apply its stored-input renames to hosted calculations - #226
Merged
Merged
Conversation
.py 6.7.5 is the next model identity for both environments. Its `us` extra pins the same packages as 6.4.1 (policyengine-us 2.2.1, policyengine-core 3.33.0, spm-calculator 1.0.0), and its bundle certifies the same national dataset, populace-us-2024-spm-20260915: the bundle's US build ID, certification, certified data artifact, default dataset URI, release manifest and every file record the hosted runtime checks are unchanged. 6.7.5 changes only the ACS local-area dataset and the state and congressional-district region datasets, which the hosted runtime does not load. Both locks were regenerated with their documented commands, run in place so the existing pins act as preferences; the only pin that changes is policyengine 6.4.1 -> 6.7.5. Every pin in both locks exists on PyPI, and every hash in backend/requirements.lock is one PyPI publishes. The variable catalog was regenerated from the reviewed H5 under the new stack. Its variables are unchanged; only its recorded .py version moves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reviewed H5 stores each person's WIC take-up decision as `would_claim_wic`. policyengine-us 2.2.1 renamed that input `takes_up_wic_if_eligible`, defaults it to true, and skips stored columns it does not define, so every hosted calculation treated every WIC-eligible person as enrolled. .py maps such renames (`legacy_inputs.LEGACY_INPUT_RENAMES`), but only in its own loaders, and the hosted runtime and the evaluation harness construct policyengine_us Microsimulation directly. .py's managed_microsimulation cannot replace that construction: it takes only a dataset path (a local file needs allow_unmanaged and loses its certified identity), builds every economic-assumption year, and cannot take the in-memory California subset. Both paths therefore call the step managed_microsimulation calls, `policyengine.tax_benefit_models.us.legacy_inputs.apply_legacy_input_renames_to_microsimulation`, on the simulation they build. The mapping is not reimplemented here; it turns itself off once the data stores the live name. Each calculation response now records the renames applied per scope in `execution.legacy_input_renames`, and the image build-time verification binds the .py function and records the renames the pinned model needs. On the reviewed national file, national WIC falls from $11.52 billion to $6.63 billion and weighted recipients from 12.65 million to 6.66 million. The deployment checks' values are unchanged: .py's legacy SPM handling is registered only for ACS local-area files, and its SPM selection equals policyengine-us's default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
anth-volk
added a commit
that referenced
this pull request
Oct 19, 2026
Bring in #216 (bounded collector run listing), #222 and #226 (.py pins, locks, the variable catalog and hosted-runtime docs). #216 changed telemetry-collector-client.ts, which this branch had left alone while that change was in flight, so its type import can now move to the package. Git merged without conflicts. build-runs.ts carries this branch's package import paths and #216's limit-bounded loadCollector. HOSTED_RUNTIME.md carries #222's model-identity section and this branch's deploy-install sentences, in separate sections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
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.
Fixes #225
Summary
policyengine[us]==6.7.5(not 6.7.6) for the hosted runtime (backend/requirements.txt) and the root evaluation harness (pyproject.toml).usextra pins the same packages as 6.4.1: policyengine-us 2.2.1, policyengine-core 3.33.0 and spm-calculator 1.0.0.populace-us-2024-spm-20260915. The US build ID, certification, certified data artifact (sha2566496cc43…aee84), default dataset URI, release manifest and every file record thathosted_release.pychecks are unchanged.would_claim_wic. policyengine-us 2.2.1 renamed that input totakes_up_wic_if_eligible(defaultTrue) and skips the stored column. Because the hosted runtime constructspolicyengine_us.Microsimulationdirectly, production treated every WIC-eligible person as enrolled.How the data is loaded
managed_microsimulation: .py's public loader doesn't fit the hosted runtime, for three reasons.allow_unmanaged=True, and then loses its certified identity.Microsimulation(dataset=path), which allocates every economic-assumption year. The hosted runtime builds a one-yearUSMultiYearDatasetto avoid that.managed_microsimulationitself calls:policyengine.tax_benefit_models.us.legacy_inputs.apply_legacy_input_renames_to_microsimulation.USMultiYearDatasetholds.takes_up_wic_if_eligiblefrom the storedwould_claim_wicfor each month.policyengine.tax_benefit_models.usdoes not re-export it. That gap is what Provide an API to resolve, verify and load the datasets .py certifies policyengine.py#667 describes.execution.legacy_input_renames(for example{"national": {"would_claim_wic": "takes_up_wic_if_eligible"}}).verify_hosted_runtime.py, which runs during the image build, now binds the .py function. It also records the renames the pinned model needs, as .py computes them.populace_us_2024_acs_localSHA-256s. The national file is not one of them.resolve_spm_selection(None)equals policyengine-us's default provider: forecast3d86d5c4…, scenarioce_trend, county geography, 2020 vintage.Commits
35dff74Pin .py 6.7.5 for the hosted runtime and the evaluation harnesstest_model_dependency_pins.py,test_hosted_release.py,test_hosted_runtime_verification.pyandtest_modal_endpoint.py) and 2 root. The cause in each case: the config still named 6.4.1 while 6.7.5 was installed or expected.test_variable_catalog.py); root 38 passedbc63330Apply .py's stored-input renames in hosted calculations and the harnesspolicyengine6.4.1 → 6.7.5.uv.lock). Every hash inbackend/requirements.lockis one PyPI publishes.WIC evidence
Fixture tests:
frontend/tests/test_stored_wic_take_up.pycovers the national scope and the California scope throughcalculate_variables.tests/test_microcosm_stored_wic_take_up.pycovers the harness.would_claim_wic = Falseand one withTrue.takes_up_wic_if_eligible = Falseandwic = 0, and the claiming child keeps $701.55.Real data: one before-and-after run on the reviewed national file, using a local, sha256-verified copy.
wic, 2024 totaltakes_up_wic_if_eligible, JanuaryTruecount)wic, 2024 totalspm_unit_spm_threshold(deployment check)ca_income_tax, 3,876 tax units (deployment check)Other variables that include WIC change as well, such as
spm_unit_benefits,household_benefitsand the SPM resource and poverty measures built on them.Deploy implications
deploy.ymlafter CI. It deploys the Modal backend, checks real national (spm_unit_spm_threshold) and California (ca_income_tax) calculations, then promotes. Today's deploy took 179 s for those calculations, of 790 s allowed.verify_hosted_runtime.py, which now imports .py.us_latest, which repopulates the variable and parameter metadata from the already loaded policyengine-us system. That took about 5 s locally.release_manifest.jsonto huggingface.co, with a 30 s timeout. If the request fails, .py falls back to its bundled certification; locally, the import succeeded with DNS blocked.materialize_dataset, whose default destination is./data. The H5 is still downloaded only by the existinghf_hub_downloadcall, into/tmp/huggingface/hub.Deployment verification: environment variables
CALIBRATION_MODAL_APP_NAMEbackend/modal_app.pydeploy.ymlstep outputsteps.identity.outputs.modal_appenv:of "Deploy Modal backend"; baked into the image by.env()deploy.ymlandmodal_app.pyCALIBRATION_SOURCE_COMMIT,CALIBRATION_SOURCE_TREE_SHA256modal_app.py,runtime_identity.pymodal_app.pyat deploy time.env()CALIBRATION_REQUIREMENTSverify_hosted_runtime.pymodal_app.pyimage.env()(/root/backend/requirements.txt)run_commands/rootlayoutPYTHONPATHmodal_app.pyimage.env()(/root)HF_HOME,HF_HUB_CACHE,XDG_CACHE_HOME,HF_HUB_DISABLE_XETmicrocosm_variable_core.py(os.environ.setdefault)/tmp/tmpis the container's writable diskPOPULACE_HF_REPO,POPULACE_HF_REVISIONbackend/variable_endpoint.pyPOLICYENGINE_SKIP_COUNTRY_IMPORTS(new to the runtime, through the .py import)policyengine/__init__.py.env().web_appattaches no Modal secretsHUGGING_FACE_TOKEN,HF_TOKEN,HUGGINGFACE_HUB_TOKEN(new to the runtime, through the .py import)policyengine.provenance.manifest.hugging_face_auth_headers, for the release-manifest GETweb_apphas nosecrets=and the image sets none.HF_RELEASE_READ_TOKENreaches only Vercel, asHF_TOKEN(deploy-dashboard.sh deploy_frontend)policyengine/populace-usis public: the request is unauthenticated, and a failure falls back to the bundled certification. Whether the GET succeeds from the Modal container is unverified; the container already downloads the H5 from the same hostMODAL_TOKEN_ID,MODAL_TOKEN_SECRETdeploy.ymlenv:indeploy.ymlChecks run locally
These mirror CI's
hosted-pythonjob, in a fresh Python 3.12 environment:uv pip install --require-hashes -r backend/requirements.lock, followed by pytest, httpx 0.28.1 and modal 1.5.5;uv pip check, which was clean;verify_hosted_runtime.py, which passed;pyteston the changed and added files plus the certificate and catalog tests: 52 passed;/rootlayout andCALIBRATION_REQUIREMENTS/PYTHONPATHset as the image sets them: passed;verify_hosted_runtime.py --dataset-filewith the real H5 and the published manifests: passed;Not changed
frontend/HOSTED_RUNTIME.md: left unchanged because Extract the calibration tree builder into a self-contained workspace package #220 edits it.frontend/scripts/generate_variable_catalog.py: still builds a plain simulation, because it lists variable metadata only and stored input values do not affect it.🤖 Generated with Claude Code