Match races by circuit id (Qatar 404), keep schedules, fix posters, add the example site #7

Merged
mesh-tools merged 20 commits from fix/match-circuits-by-id into master 2026-11-27 09:56:42 +00:00
Collaborator

Brad Johnston reported (mail of 2026-11-27) that the 2025 and 2026 Qatar Grand Prix posters answer 404: Jolpica names the circuit Lusail, circuits.json Losail, and races were matched by name. Every Qatar race since 2021 failed.

What this changes:

  • Races are matched on Jolpica's circuitId: each circuit in circuits.json carries its ergastId (tests hold one unique id per circuit and that a race resolves by it).
  • Each track format serves its own file (png and geojson served the SVG), so the GPS traces are served at last.
  • Jolpica schedules: one client, finished seasons kept on disk, requests paced under 4/s, a 429 retried after its Retry-After, a failure never kept and not asked again for ten minutes, 30 s timeout. (A Kometa request on 2026-11-27 09:28 kept 24 seasons empty until a restart, so their posters answered 404.)
  • Posters: CARTO's basemaps now need a key, so dark, light and the world locator use Esri's grey canvases (max zoom 16); a map is drawn only when every tile came and they are not one placeholder picture; a poster whose map or photo failed is served for five minutes and not stored; render routes run in the threadpool; tiles fetched in parallel (6 at once to Esri, 2 to OpenStreetMap); posters sent with an ETag and a day's cache.
  • One access-log line per request with the visitor's address (X-Forwarded-For); uvicorn trusts the proxy's headers, so /examples redirects to https.
  • An example site at /examples/ (one page per route, a GPS-trace map, posters, Kometa, and a browsable library season → race → sessions); the root lists the real routes.
  • README rewritten (37 of 39 links were broken), with a test that every link leads to a file.
  • Cleanup: copies, backups and caches nothing reads (cache/ was 562 MB of FastF1 downloads).
  • Data: Le Mans 1965 → 1967, Sepang 1999-2017 → 1999- (a 2026 race), PNGs for the Indianapolis oval and Madring.
  • Includes #6's two manifest commits unchanged (version 0.1, cache declared in data.own); #6 is closed as replaced.

Not in this change: the season photos (the dilbert bucket refuses anonymous reads, issue 1986), three layouts with empty traces (Mont-Tremblant, Buddh, Korea) and Madring's point, overlapping layout years (Bahrain 2010, Sakhir 2020, Hungary 1989), and a disk tile store (taken out after review; to come back designed whole).

Reviewed in four rounds (the fourth over the three-round limit, said to the operator).

Reviewed-by: reviewer@shanks at 6e62440102

https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh

Brad Johnston reported (mail of 2026-11-27) that the 2025 and 2026 Qatar Grand Prix posters answer 404: Jolpica names the circuit Lusail, circuits.json Losail, and races were matched by name. Every Qatar race since 2021 failed. What this changes: - Races are matched on Jolpica's circuitId: each circuit in circuits.json carries its `ergastId` (tests hold one unique id per circuit and that a race resolves by it). - Each track format serves its own file (png and geojson served the SVG), so the GPS traces are served at last. - Jolpica schedules: one client, finished seasons kept on disk, requests paced under 4/s, a 429 retried after its Retry-After, a failure never kept and not asked again for ten minutes, 30 s timeout. (A Kometa request on 2026-11-27 09:28 kept 24 seasons empty until a restart, so their posters answered 404.) - Posters: CARTO's basemaps now need a key, so dark, light and the world locator use Esri's grey canvases (max zoom 16); a map is drawn only when every tile came and they are not one placeholder picture; a poster whose map or photo failed is served for five minutes and not stored; render routes run in the threadpool; tiles fetched in parallel (6 at once to Esri, 2 to OpenStreetMap); posters sent with an ETag and a day's cache. - One access-log line per request with the visitor's address (X-Forwarded-For); uvicorn trusts the proxy's headers, so /examples redirects to https. - An example site at /examples/ (one page per route, a GPS-trace map, posters, Kometa, and a browsable library season → race → sessions); the root lists the real routes. - README rewritten (37 of 39 links were broken), with a test that every link leads to a file. - Cleanup: copies, backups and caches nothing reads (cache/ was 562 MB of FastF1 downloads). - Data: Le Mans 1965 → 1967, Sepang 1999-2017 → 1999- (a 2026 race), PNGs for the Indianapolis oval and Madring. - Includes #6's two manifest commits unchanged (version 0.1, cache declared in data.own); #6 is closed as replaced. Not in this change: the season photos (the dilbert bucket refuses anonymous reads, issue 1986), three layouts with empty traces (Mont-Tremblant, Buddh, Korea) and Madring's point, overlapping layout years (Bahrain 2010, Sakhir 2020, Hungary 1989), and a disk tile store (taken out after review; to come back designed whole). Reviewed in four rounds (the fourth over the three-round limit, said to the operator). Reviewed-by: reviewer@shanks at 6e624401028e2f7c444846a4e9326c7c093d123c https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
mesh-tools added 20 commits 2026-11-27 09:56:27 +00:00
No version is published for it (builder_versions answers none), so §583 gives 0.1.

Builds: design 47 G A-335, §583

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
Declare the written directory in data.own (cache class)
mesh/merge-gate waiting in the build queue since 08:56
mesh/delivery-group group feat/47-G-join11 checking: composed again for its members' new heads
mesh/delivery ready: it is merged on the Approve
60c4f20158
Builds: design 47 G, lead answer A-338, ADR 0233

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
Jolpica renamed Losail to Lusail International Circuit, so the name match
found no circuit and every Qatar Grand Prix poster, thumb and track image
answered 404 (reported by Brad Johnston for 2025 and 2026; every season
since 2021 failed). Names drift, ids do not: each circuit in circuits.json
now carries its ergastId, the lookup keys on it, and the poster's zoom
fallback resolves our circuit slug the same way. The name match also sent
Caesars Palace (1981-82) to the Las Vegas Strip circuit; by id it resolves
to nothing, as there is no layout of it.

tests/ checks every circuit has one unique ergastId and that a race
resolves by id; the merge check runs it.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
/png and /geojson answered the SVG file under a PNG or GeoJSON media
type, so the GPS-traced GeoJSON of a layout was never served at all.
Each format now serves its own file; a layout without one answers 404.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
Nothing reads them, and each is a copy of what stays or can be fetched
again:
- cache/: FastF1's download cache (93 files, 562 MB) of the trace
  generator; it fetches it again when run.
- circuits_bak/: the circuit tree before its move to lowercase slugs; 117
  of its 118 traces are identical in circuits/, the last is a FastF1
  sketch in metres, not a GPS trace.
- Grand Prix/: 18 traces filed by race name, all identical in circuits/.
- Data/circuits.json: the circuit list in its first format.
- __pycache__/, .idea/: bytecode and editor settings.
- fast_f1_service.py: an empty file.

.gitignore had ".nova__pycache__/" on one line, so neither applied; it now
ignores .nova, __pycache__/, cache/ and .idea/.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
A Kometa YAML request asks Jolpica for every season at once; Jolpica
(4 requests a second, 500 an hour) answered 429 for 24 seasons on
2026-11-27 09:28, and lru_cache kept each failure as an empty schedule,
so every poster and thumb of those seasons answered 404 until a restart.
The service also ran two Jolpica clients, so the race lookup and the
posters held different schedules.

Now one client serves the whole service; a season that is over is kept
on disk in the cache volume for good, one not yet over is asked again
after six hours; requests are paced under the limit, a 429 is asked
again after its Retry-After; a failure is never kept. The Kometa
endpoint runs in the threadpool, as its first fill takes minutes.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
Uvicorn's access log named only the proxy (172.17.0.1), with no time
taken or client. Each request is now one line: the visitor's address
from route-proxy's X-Forwarded-For, the request, status, size, duration,
referrer and user agent; uvicorn's own access log is off.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
A reader learns the API fastest from working calls: one page per area
(circuit browser, track images, GPS traces on a map, grand prix lookup,
posters, Kometa) shows the exact request URL next to its answer. Pages
call their own origin when the app serves them, and the public service
when opened from disk or given ?api=. Posters render only on a button
press, since each one fetches map tiles on the server. A body that does
not match the asked format is said in red, never shown as success.

The image copies examples/ so the deployed app serves the same pages.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
The root's list named a /grand-prix/{name}/year/{year} route and a
/tracks/.../layout/... route that do not exist, and left out the
per-layout file route, the session thumbs and the Kometa metadata, so a
reader of / was sent to addresses that answer 404.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
37 of its 39 links to files of the repository led nowhere: they named
the upstream's flat circuits/<id>.geojson, not this repository's
circuits/<country>/<locality>/<circuit>/<layout>.geo.json. It now says
what the API serves, where the example site is, how the data is laid
out, and lists every circuit with its Jolpica id and a link to each
layout's GPS trace, written from circuits.json. A test holds every
local link to a file.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
CARTO's basemaps now need an API key and answer every tile with an "API
KEY REQUIRED" picture under a 200, so the dark and light backgrounds and
the world locator showed that text. They now use Esri's grey canvases,
which need no key and draw to zoom 16; each provider names its deepest
zoom, and a race poster resolves its position once, capped to it, for
the map, the projected track and the locator alike. One tile stitcher
replaces three copies and refuses a map whose tiles are all the same
picture: a provider's placeholder is said in the log, not drawn.

A race poster, a thumb or a season poster whose map or photo failed is
served but no longer kept, so the next ask renders it again; race
posters carry a render version in their file name, so those drawn over
CARTO's placeholder are rendered again.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
Review round 1 (two findings):
- While Jolpica failed, every schedule read asked it again, up to four
  times per poster request, and the poster, thumb and grand-prix routes
  were async, so the pacing, a 429's pause and a timeout stalled every
  request. A failed ask is now remembered for ten minutes (the kept
  schedule, or none, is answered meanwhile), a schedule in memory is
  answered without waiting for an ask under way, and those routes are
  plain defs in the threadpool. A rendered picture is stored whole
  (written aside, then renamed), as two may now render it side by side.
- Bytecode was tracked: tests/__pycache__ (added with the tests) and
  models/__pycache__ that the cleanup missed. Untracked; .gitignore
  already names __pycache__/.

From the review's notes: a poster whose map or photo failed is sent with
a five-minute cache instead of a year's; uvicorn trusts the proxy's
forwarded headers, so /examples redirects to https, not http; stale
comments naming CARTO and the zoom lookup's key are corrected.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
A race poster took 8.8 s, 78% of it fetching 40 map tiles one by one,
and every poster, thumb and locator of the same circuit fetched the same
tiles again. Tiles are now kept on disk in the cache volume for 30 days
(stored only once the stitch is no placeholder) and fetched in parallel,
at most 6 at once per Esri service and 2 for OpenStreetMap, as its tile
usage policy asks, across every render. Measured: a poster of a new
circuit 2.4 s, of a known one 0.8 s; a weekend's first thumb 1.4 s, each
further thumb 0.8 s (was about 12 s each). PNGs are saved without
optimize (1.6 s less per render, 2% larger).

A stored poster is sent with an ETag and a day's cache instead of a
year's, and an If-None-Match that matches gets a 304, so a poster whose
look changes reaches clients within a day.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
The operator wants to browse the posters the way a Plex or Emby Formula 1
library shows them. The page reads the whole library from the one Kometa
file (rounds, race names in the race posters' addresses, sessions in the
episodes'), waits through a fresh server's minutes-long first answer
instead of failing, and loads each picture only when it is on screen, two
at a time, dropping the queue when the reader leaves a level: every
poster is a render of about 10 s that pulls map tiles. Each level has its
own address and back/forward work; a picture the server has none for is
a plain card with its name.

The session order per weekend format moves into site.js, so the posters
page and the library read the same list.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
Jolpica answers a season it has not served lately in over 10 s (13.5 s
for 2024 on 2026-11-27), so a cold fill timed out 18 seasons and the
Kometa file and the library page went without them until asked again
(found by the library page's test).

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
The Bugatti Circuit held one Grand Prix, in 1967 (1965 is when it opened),
and Sepang returns in 2026 on the same track, so its layout runs on from 1999.
A race resolves its layout by year, so the old names missed 1967 and 2026.
The README's circuit table is regenerated from circuits.json to follow.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
Both layouts had a trace or a path but no PNG, so their png route found no file.
They are drawn as every other PNG here was: matplotlib 3.10.1, a 10 x 8 inch
figure, a black 2-point line at equal aspect, margins 0.1, tight layout, saved
transparent with a tight box (all 117 existing PNGs redraw pixel for pixel this
way). Madring has no GPS trace, so its hand-made SVG path is drawn instead.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
Review round 2: with part of a map's tiles on disk, the placeholder
check saw several pictures and let a provider's placeholder through,
drew it and kept it for 30 days. The tiles fetched now are judged on
their own: two or more that are all one picture matching no kept tile
are a placeholder, and the map fails whole (nothing drawn or kept, the
poster served for five minutes). A real uniform tile, such as open sea,
matches one kept before and passes.

From its notes: the request slots are per tile host, so the satellite
and both grey canvases share Esri's six; a weak If-None-Match matches;
the README says a poster is kept once its map or photo came.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
Review round 3 found two more holes in the disk tile store: a lone
fetched placeholder tile could not be judged and was kept, then vouched
for its neighbours; and a map with some tiles on disk and the rest
refused counted as whole, so a poster with black squares was kept for
good. Three rounds on one part: the store is taken out of this change,
to come back designed whole (placeholders remembered, a lone tile
judged against a fresh neighbour).

Tiles are fetched in parallel as before, all from the network. A map is
drawn only when every tile it needs came and they are not all one
picture; otherwise it is None, and its poster or thumb is drawn
without it, served for five minutes and not kept. A race poster is kept
only when its world locator came too.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
mesh-tools merged commit d7b5df3c40 into master 2026-11-27 09:56:42 +00:00
mesh-tools deleted branch fix/match-circuits-by-id 2026-11-27 09:56:46 +00:00
Author
Collaborator

{
"records": [
{
"instance": "record/master_2_6e21786f",
"sequence": 131191,
"bytes": 733,
"of-bytes": 65536,
"record": {
"milestone": "master.2",
"branch": "master",
"source": 2,
"call": "7e483f0e168c6d09",
"heads": {
"jschoubben/f1-circuits@7": "d7b5df3c40fcb6a0d1b471c196258b9a2cbdfa9f"
},
"opened": "2026-11-27T10:00:33.01104658Z",
"form": 3,
"ended": {
"at": "2026-11-27T10:04:39.922626765Z",
"why": "failed: required steps not passed: f1-circuits composition not asked"
},
"ends": 1,
"pipeline-ends": 1,
"movers": 1,
"merge-called": "2026-11-27T09:56:49.464Z",
"phases": {
"build": {
"end": "2026-11-27T10:04:11.809440295Z",
"start": "2026-11-27T10:04:03.555500791Z"
},
"ended": "2026-11-27T10:04:14.367468324Z",
"placed": "2026-11-27T10:04:03.555500791Z",
"taken": "2026-11-27T10:01:12.809899281Z",
"validate": {
"end": "2026-11-27T10:04:14.367468324Z",
"start": "2026-11-27T10:04:03.555500791Z"
}
}
},
"movers-per-outcome": {
"bypassed": 1,
"could not run": 1,
"not asked": 1,
"passed": 1,
"taken-in": 1,
"waiting": 1
}
}
]
}

<!-- mesh-delivery:view --> { "records": [ { "instance": "record/master_2_6e21786f", "sequence": 131191, "bytes": 733, "of-bytes": 65536, "record": { "milestone": "master.2", "branch": "master", "source": 2, "call": "7e483f0e168c6d09", "heads": { "jschoubben/f1-circuits@7": "d7b5df3c40fcb6a0d1b471c196258b9a2cbdfa9f" }, "opened": "2026-11-27T10:00:33.01104658Z", "form": 3, "ended": { "at": "2026-11-27T10:04:39.922626765Z", "why": "failed: required steps not passed: f1-circuits composition not asked" }, "ends": 1, "pipeline-ends": 1, "movers": 1, "merge-called": "2026-11-27T09:56:49.464Z", "phases": { "build": { "end": "2026-11-27T10:04:11.809440295Z", "start": "2026-11-27T10:04:03.555500791Z" }, "ended": "2026-11-27T10:04:14.367468324Z", "placed": "2026-11-27T10:04:03.555500791Z", "taken": "2026-11-27T10:01:12.809899281Z", "validate": { "end": "2026-11-27T10:04:14.367468324Z", "start": "2026-11-27T10:04:03.555500791Z" } } }, "movers-per-outcome": { "bypassed": 1, "could not run": 1, "not asked": 1, "passed": 1, "taken-in": 1, "waiting": 1 } } ] } <!-- mesh-act:view.record/master_2_6e21786f.jschoubben/f1-circuits#7@1795773880024721851.c72d18d6 -->
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jschoubben/f1-circuits#7