Repository navigation
Package UK area lists and certify UK regional releases - #615
Draft
juaristi22 wants to merge 1 commit into
Draft
juaristi22 wants to merge 1 commit into
juaristi22 wants to merge 1 commit into
Conversation
Ship the 650 constituencies (2024) and 361 local authorities (April 2023, with Ards and North Down and real hexes for the 2023 unitaries) with the package. Area regions and geography output labels read them instead of GCS; the opt-in registry previously came back empty because its GCS helper no longer exists in policyengine-core. Extend --regional-manifest-uri to the UK: a Microcosm local-area release routes constituency and local-authority regions to its file, and --regional-release-kind area_coded_national routes them to the enhanced FRS with its weight matrices at their own revision, for a national-first switch. Certification records regional_release_kind, checks the regional release's own model compatibility, HEAD-checks carried and Microcosm UK artifacts, refuses re-certification that would drop regional routing, and names a build by its cut tag. Area regions take the routed dataset and join the default registry only for a local-area release. Add the Universal Credit coverage floor check from #491. Refs #553 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been 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.
Part of #553 (the infrastructure half; the certification PR will close it)
The infrastructure half of #553. The UK default stays the enhanced FRS 1.58.0 for now, so
manifest.jsonand both TRO sidecars are unchanged. This PR adds what a later certification PR needs to switch the default to a Microcosm national release. That works with a Microcosm local-area release, or, if the national release is ready first, with the enhanced FRS serving constituency and local-authority runs.Packaged area lists
src/policyengine/data/uk_geography/shipsconstituencies_2024.csvandlocal_authorities_2023.csv. Their sources and hashes are inSOURCES.md.N09000011), and the four 2023 unitaries get their own hexes instead of a shared (0, 0).mainthe opt-inbuild_uk_region_registry(include_constituencies=True, include_local_authorities=True)returns no areas: the GCS helper it imports no longer exists in policyengine-core 3.33.0, and the loader swallows theImportError.compute_uk_constituency_impactsandcompute_uk_local_authority_impactslabel areas from the packaged lists. An explicit CSV path still wins. They no longer search local folders or download from GCS, because the local search included the old download cache and would prefer a stale 360-row file.local_authorities_2021.csv) are untouched. A matrix indexes areas by that file's row order, and sim-api's fallback depends on it.UK regional certification (
certify-data --regional-manifest-uri)#552's regional path was US-only. It now covers both UK cases:
Ship together: a Microcosm
non_default_local_arearelease routesregion_datasets.constituencyand.local_authorityto its H5. This recordsregional_release_kind: local_area.National first:
--regional-release-kind area_coded_nationaltakes a certified policyengine-uk-data release, such as the enhanced FRS 1.58.0 manifest. It carries:weightsartifacts: the constituency and local-authority matrices andlocal_geography_weights.All of them keep their own repo and revision, so sim-api's same-release matrix binding still holds. The constituency and LA region types route to the enhanced FRS, and the run records
regional_release_kind: area_coded_national.Either way:
uk_area_regions_routed.Guard: re-certifying a bundle that routes regions, without
--regional-manifest-uri, is refused instead of silently dropping the routing.--drop-regional-releaseremoves it on purpose. This applies to the US as well and automates the runbook's "still pass--regional-manifest-uri".Cut tag as build identity
Microcosm keeps
build.build_idequal to the line name on every cut and records the cut inbuild.cut_tag. Certification and the import-time compatibility check both use the cut tag when there is one, throughrelease_build_id. It feedsversion,data_build_idand the changelog fragment name, so two cuts of one line no longer look identical. Releases without a cut tag, such as the enhanced FRS, are unchanged.UK region routing
dataset_path=resolve_region_dataset_path("uk", …)and keep their row filters. That isNonetoday, so behaviour is unchanged.build_uk_region_registry()adds the area regions by default only whenregional_release_kind == "local_area". ExplicitTrue/Falsestill wins.Universal Credit coverage floor (#491)
scripts/check_uk_uc_floor.pychecks two Great Britain measures, each within 10% of its benchmark:These are the figures policyengine-uk-data calibrates to. Sources are in
data/qualification/uk_uc_floor.json. The receipt holds weighted national totals only. On the enhanced FRS 1.58.0 at 2025 it passes: benefit units at 0.925 of DWP's figure and spend at 0.979 of the OBR's.Checks
test_uk_area_lists.py,test_uk_uc_floor.py, UK merge and end-to-end certification tests (both modes, the compatibility refusal, the re-certification guard, cut-tag identity, the sim-api predicate), UK routing tests, and a runtime cut-tag test.bundle.py check --include-trospasses, andsrc/policyengine/data/bundle/is unchanged.…5c6b3f68was certified national-first against the enhanced FRS 1.58.0 manifest.enhanced_frs_2024_25.h5, with the matrices atpolicyengine-uk-data-private@1.58.0, and names the cut tag as the build.Follow-up (certification PR, not this one)
dataset_overlays.ukentries for the enhanced-FRS names no longer certified.🤖 Generated with Claude Code