You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Request UK constituency and local-authority impacts separately from the national economy result #4021
.py 6.10.0 runs UK national economy reports on a national dataset (microcosm_uk_2024_25) that has no area codes, so a national run no longer returns constituency or local-authority impacts. The simulation API (PolicyEngine/policyengine-sim-api#881) adds a separate run on the local-area dataset that returns only those impacts. The Public API needs a way to ask for that run.
What changes in the Public API
The annual economy route, GET /{country}/economy/{reform}/over/{baseline}, accepts a new optional query parameter, breakdown=local_areas. The budget-window route does not accept it.
The parameter is valid only for the UK, with region set to uk or a UK country (country/*), and not with target=cliff. Any other combination, or any other value, returns HTTP 400.
When the parameter is set, it becomes part of the calculation options, so the request gets its own options hash and its own cached result. Requests without it keep their current options hash and cached results.
The Public API sends "breakdown": "local_areas" to the simulation API only when the parameter is set, and stores and returns the result the simulation API sends back (kind: "local_areas", with constituency_impact and local_authority_impact).
If the simulation API refuses a breakdown request with HTTP 400 or 422 (for example, because the deployed .py release cannot run it), the Public API returns a 502 error that says so, instead of a generic 500.
UK reports for Northern Ireland use country/ni in the Public API's metadata, but .py's region registry names that region country/northern_ireland. The Public API translates the name when it builds the simulation request.
This change has to merge after the simulation API change (PolicyEngine/policyengine-sim-api#881) is deployed with .py 6.10.0, and after the app change that requests the breakdown is merged.
Activity
Accept only uk and the published UK country codes for a breakdown
Test that a completed breakdown is stored and returned unchanged
Share one type for the local_areas breakdown value
Name each rejected field in every simulation API 422 message
Mark local-area breakdown runs in the simulation telemetry
Give UK area regions the local-area dataset in the v2 catalog
Don't keep a failed or wrong-kind breakdown job for replay
List every accepted breakdown region in the 400 and the query descrip…
Test the Northern Ireland breakdown end to end and the early rejection
Keep a failed breakdown's error for two minutes on its own record
Note that UK national results no longer carry area impacts
Add Ards and North Down and the 2023 unitaries' positions to the UK list