Repository navigation
Admit UK datasets without area codes only when local-area runs are routed, and guard the weight-matrix fallback #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a9e5971
9821812
1442197
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,28 @@ def validate_uk_local_authority_metadata( | |
| country: CountryId, | ||
| baseline: UKLocalAuthorityMetadata | None, | ||
| reform: UKLocalAuthorityMetadata | None, | ||
| *, | ||
| region_code: str | None = None, | ||
| ) -> UKLocalAuthorityMetadata | None: | ||
| """Require matching UK authority metadata and reject it elsewhere.""" | ||
| """Require matching UK authority metadata and reject it elsewhere. | ||
|
|
||
| Retained artifacts are read without rerunning dataset detection, so a UK | ||
| pair without metadata passes only with the same evidence detection needs: | ||
| the report's region is national or nation-level and the bundle routes | ||
| both constituency and local-authority regions to another dataset. | ||
| """ | ||
|
|
||
| if country == "uk": | ||
| if baseline is None and reform is None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This accepts every pair of UK artifacts whose boundary metadata is absent, but the coordinator can deserialize retained artifacts without rerunning
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 1442197.
|
||
| from policyengine_simulation_executor.uk_local_authority_metadata import ( | ||
| uk_area_codes_required, | ||
| ) | ||
|
|
||
| if region_code is None or uk_area_codes_required(region_code): | ||
| raise ValueError("UK simulation artifact metadata is missing") | ||
| return None | ||
| if baseline is None or reform is None: | ||
| raise ValueError("UK simulation artifact metadata is missing") | ||
| raise ValueError("UK simulation artifact metadata is missing on one side") | ||
| if baseline != reform: | ||
| raise ValueError("UK simulation artifact boundary versions do not match") | ||
| return baseline | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matching the matrix year and household dimension does not establish that this matrix belongs to the selected dataset.
WeightReplacementStrategy.applyassigns a matrix row positionally, so a matrix from another dataset revision or household ordering will pass this check whenever it has the same number of households and can attach weights to the wrong records. Please bind the matrix to the certified dataset revision or digest, or validate equivalent provenance that covers household ordering.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed: the shape check couldn't tell releases apart. uk-data 1.57.4's constituency matrix is 650 × 52,846 like the certified 1.56.16 one, and its enhanced FRS has the same 52,846 households in a different order. Fixed in 1442197:
download_missing_assets=False). Every uk-data release overwrites that object, so it was never bound to the certified dataset._require_certified_uk_weight_matrixtakes the matrix the bundle certifies in the same release (repository and revision) as the selected dataset. It materializes that matrix through policyengine.py's digest-checked materializer, where the strategy looks first, and confirms the strategy resolves exactly that file before the run. The year and household checks stay as a last sanity check.6870c360…) and passed for the 52,846-household enhanced FRS.This surfaced two things, now noted in the PR description:
73944f69…), its constituency and local-authority results will change when this deploys. Someone with bucket access can confirm by comparing the object's digest with6870c360….KeyErrorinside policyengine.py; now it's a clear message.