Repository navigation
UK breakdowns: start in the background, poll through brief failures, time limit, measured estimate, nation withheld counts, map credit - #1427
Merged
Conversation
…nt nation withheld areas and credit map downloads - useUKLocalAreaBreakdown: a computing run outlasts up to three failed polls in a row, and fails with Retry once it computes past UK_LOCAL_AREA_BREAKDOWN_TIME_LIMIT_MS. - countWithheldUKAreas: a nation report counts its published areas by ONS code against the nation's areas in the boundary files (UK_AREA_COUNTS_BY_NATION, checked against the files by a test). - UKAreaChoroplethMap: the export ref wraps the frame and the boundaries' Open Government Licence credit, so PNG and SVG downloads include it. Part of #1411. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UK-wide 267 s on a cold worker and 154 s on a warm one, Wales 46 s, on the Public API on 26 October 2026. Part of #1411. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…akdown-followups # Conflicts: # app/src/tests/unit/data/ukBoundaryFiles.test.ts
anth-volk
approved these changes
Oct 27, 2026
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.
Part of #1411. Follow-ups to #1398's on-request UK local-area breakdowns.
Changes
Polling outlasts brief failures (
useUKLocalAreaBreakdown). A computing run keeps polling through up toMAX_FAILED_POLLS(3) failed polls in a row, for example a gateway 502, because the job may still run on the server. The next failure after that, or a failure before the run is known to be computing, still ends it as an error.Time limit. A run that computes for longer than
UK_LOCAL_AREA_BREAKDOWN_TIME_LIMIT_MS(30 minutes) ends with an error and Retry. Retry checks the same run again with a fresh clock.Measured duration.
UK_LOCAL_AREA_BREAKDOWN_DURATION_MSis now 270 s, from runs on the Public API on 26 October (.py 6.10.0), submission to completion:The API's stages keep a faster run's progress bar honest.
Exact withheld counts for nation reports (
countWithheldUKAreas). A nation report counts its published areas by ONS code against the nation's areas in the shipped boundary files (UK_AREA_COUNTS_BY_NATION: constituencies E 543, W 32, S 57, N 18; local authorities E 296, W 22, S 32, N 11). A new test inukBoundaryFiles.test.tschecks these numbers against the files. A count is given only when every published area has a code in the nation; otherwise the note keeps its wording without a number, as before. UK-wide reports keep the existing count against the region metadata.Licence credit in map downloads (
UKAreaChoroplethMap). The export ref now wraps the map frame and the ONS / Open Government Licence credit under it, so PNG and SVG downloads include the credit. Tooltip positioning still measures the frame.Not in this PR (left open on #1411)
Testing
withheldUKAreasOf); nation counts against the boundary files; the export node holds the map and its credit.bun run vitest: 457 files, 5,909 tests pass.bun run check(tsc, ESLint, Prettier) passes.Related: PolicyEngine/policyengine-sim-api#914 (reuse the baseline across breakdown runs).
🤖 Generated with Claude Code
Background start (v3)
UKLocalAreaAutoStart(commit89a7fadfd) starts the breakdown as soon as a UK-wide or nation report's national result is in, so the user no longer clicks Compute. It renders nothing; the Local areas tab follows the same run through the query key and shows its progress, then the maps, or Retry after an error. Results that already hold both levels, and results from before .py 6.10.0, start nothing. A failed run is not restarted automatically. The overview card now reads "They calculate in the background, in a few minutes." v2 is unchanged.Checked locally on report 4783: the
breakdown=local_areasrequest went when the overview loaded, and after the run finished, the Local areas tab showed the maps with no click.Cost: every opened UK-wide or nation report from .py 6.10.0 on now sends one breakdown run (cached by the API after the first). sim-api#914 (baseline reuse) would cut each run by about 50 s.