Relax manifest check + bump country-model pins to 3.9-compatible releases#282
Merged
Relax manifest check + bump country-model pins to 3.9-compatible releases#282
Conversation
`UKTaxBenefitModel.__init__` / `USTaxBenefitModel.__init__` previously raised `ValueError` on any mismatch between the bundled manifest's pinned model version and the installed `policyengine-uk` / `policyengine-us` version. That made every routine country-model patch bump require a coordinated pypkg manifest update, and when downstream core tightened its parameter validation (core 3.24.0's strict breakdown validator), every post-merge pypkg publish broke at import time because the stale pins in pypkg's extras couldn't install against modern core. Swap the `ValueError` for a `UserWarning`. Calculations now run against whatever country-model version is installed; dataset compatibility is still advertised via `model.release_manifest`, and downstream code that cares about exact pinning can inspect it. Adds a regression test verifying both models emit a UserWarning instead of raising on a version drift. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- `policyengine-us==1.602.0` -> `1.647.0` (first version with 3.9 support + breakdown fixes) - `policyengine-uk==2.74.0` -> `2.88.0` (first version with 3.9 support) - `policyengine_core>=3.23.6` -> `>=3.24.1` (includes ParameterScale fix) The stale `1.602.0` and `2.74.0` pins no longer install cleanly under modern `policyengine-core` because the strict breakdown validator added in core 3.24.0 rejects the older country-model parameter data. The post-merge push workflow for #278 surfaced this as the first test failure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Follow-up to the pyproject.toml pin bump in this PR. The
`src/policyengine/data/release_manifests/{us,uk}.json` bundled
manifests carry `model_package.version` / `built_with_model_version`
/ `certified_for_model_version` fields that are exact-matched against
the installed country-model version at `UKTaxBenefitModel.__init__`
(and equivalent in us). Bumping the pyproject pins without also
bumping the manifests would make the exact-match check fail at
import time:
ValueError: Installed policyengine-uk version does not match the
bundled policyengine.py manifest. Expected 2.74.0, got 2.88.0.
Bump the us manifest to `1.647.0` and the uk manifest to `2.88.0`
to match the new extra pins. Data-package versions (`us-data 1.73.0`,
`uk-data 1.40.4`) are unchanged — the bumped country-model releases
read the same dataset artefacts.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tests/test_models.py and tests/test_release_manifests.py had exact-string assertions on the bundled manifest version / bundle_id fields. Now that those manifest values are bumped to match the new pins (us 1.647.0, uk 2.88.0, bundle_id N.N.6), update the matching assertions. Remaining occurrences of "1.602.0" in tests/test_release_manifests.py are inside test-local fixtures that construct their own synthetic manifests; they don't reflect the bundled manifest and don't need to be bumped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The `bundle_id` / `policyengine_version` fields track the policyengine.py package version itself, not the bundled country-model versions. Bumping them to 3.4.6 broke downstream tests (`test__given_manifest_certification__then_release_bundle_exposes_it` and friends) that assert against the live pypkg version. Restore them to `3.4.0` — only the country-model version fields (`model_package.version`, `built_with_model_version`, `certified_for_model_version`) should change in this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 tasks
UKTaxBenefitModel / USTaxBenefitModel don't exist — the concrete classes are PolicyEngineUKLatest / PolicyEngineUSLatest, which is where the __init__ with the manifest check lives. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previous version fully instantiated PolicyEngineUKLatest / PolicyEngineUSLatest, but their __init__ chains into certify_data_release_compatibility which hits Hugging Face. Without HUGGING_FACE_TOKEN env, instantiation fails before the version-warn branch is exercised. Rewrite the test to patch the network-dependent downstream calls (certify_data_release_compatibility, _get_runtime_data_build_metadata, TaxBenefitModelVersion.__init__) so only the version-check branch runs. Any downstream exceptions are caught since by then the warning has already been emitted (or the raise has already fired, which would fail the test correctly). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
test__given_manifest_certification__then_release_bundle_exposes_it asserted data_build_model_version == 2.74.0 — bump to 2.88.0 (uk manifest pin). test__given_private_manifest_unavailable__then_bundled_certification_is_used passed runtime_model_version="1.602.0", which no longer matches the bundled us manifest's certified_for_model_version (1.647.0). Bump to 1.647.0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Two related changes to unblock pypkg's post-merge publish pipeline and prevent this class of breakage from recurring:
1. Relax
UKTaxBenefitModel/USTaxBenefitModelmanifest check fromValueErrortoUserWarningPreviously both models raised
ValueErroron any mismatch between the bundled manifest's pinned model version and the installedpolicyengine-uk/policyengine-usversion. That made every routine country-model patch bump require a coordinated pypkg manifest update, and when downstream core tightened its parameter validation (core 3.24.0's strict breakdown validator), every post-merge pypkg publish broke at import time because the stale pins in pypkg's extras couldn't install cleanly against modern core.Calculations now run against whatever country-model version is installed. Dataset compatibility is still advertised via
model.release_manifest; downstream code that cares about exact pinning can inspect it.2. Bump the pinned country-model versions to 3.9-compatible releases
policyengine-us==1.602.0→==1.647.0(first release with 3.9 support + breakdown fixes)policyengine-uk==2.74.0→==2.88.0(first release with 3.9 support)policyengine_core>=3.23.6→>=3.24.2(includes_fast_cache+ assert_near fixes)Without the relaxation in (1), this bump would fail old pins; without (2), the pipeline still can't install modern core. Together they land clean.
Supersedes
Closes #280 (this is #280 + the manifest-warning change from #282 merged into one PR).
Test plan
tests/test_manifest_version_mismatch.pyverifies both models emit aUserWarning(not raise) on a version drifttest_has_release_manifest_metadata/test__given_us_manifest__then_has_pinned_model_and_data_packages/test__given_uk_manifest__...updated to the new pinned versionsruff format --check+ruff checkcleanInstall + smoke-importjobs (3.9–3.14), Lint, Mypy, changelogTest (3.13)/Test (3.14)— the us/uk integration tests may still surface the upstream bugs tracked in refundable_ctc ↔ income_tax dependency cycle surfaces on itemizing branch policyengine-us#8059 (refundable_ctccycle) and Household-impact tests return 0 for expected-positive tax/benefit values on 2.88.0 policyengine-uk#1628 (household-impact zeros); those are independent of this PR and are being handled separately.