Repository navigation
chore(nws): fetch the zone dataset, verify it, then install it - #449
Conversation
Round 3 of seevee#316. The reader loads the zone dataset from a fixed path, and nothing puts a file there. providers/nws_zone_fetch.py is the one path by which a download reaches it, and the way to take the file away again. Nothing calls it yet, and it does not know where datasets are published: the caller gives the address and the SHA-256 it wants. It assumes whatever answers the request is hostile. The address must be https with no credentials and no unusual port. Redirects are followed by hand, five at most, each hop https on a host the caller allowed. The request asks for no transfer compression and a response that applies one is refused unread. Only a 200 is accepted, the body is read in chunks and abandoned past 16 MB or 120 seconds, and a size the server announced must be the size that arrives. The bytes are verified before anything is written, and only the dataset asked for is accepted: an older published one is refused, so a download cannot roll an install back. They are written to a .part file and renamed into place. The .part file is made new each time, private and exclusive, so a link, a named pipe or a stale file left at its path is never opened. Entries already running are handed the new set. Every failure raises with a reason and leaves the fixed path as it was. async_adopt_zone_data() accepts a file placed there by hand through the same check. async_remove_zone_data() deletes the file and any .part file under the lock an install holds, so it cannot take half of one. It never raises: what cannot be removed is logged by name and left. Refs: seevee#316
|
Thanks, this reads clean and I didn't find anything to change in the fetch itself. On where it's published: a release asset on this repo, as you suggest, under the name you have, I ran One nit from the run: the message reads "NWS zone data unrecognised: NWS zone data unrecognised: SHA-256 ...", the reader's prefix gets wrapped again. Merging this now, the prefix can ride with the next piece. |
|
@systems-monitor the tag I owed you: the dataset is up on https://github.com/seevee/cap_alerts/releases/download/v0.9.0-alpha.3/cap_alerts.nws_zones.jsonl.gz I rebuilt it from the April shapefiles today and got c985ed4f again, and your check script passed all ten. The download from GitHub hashes the same. So the download piece can pin that tag and file name, later releases won't carry their own copy. |
Round 3 of #316. One module,
providers/nws_zone_fetch.py, and its tests. Nothing calls it yet, so this changes nothing for any entry.It does not depend on the offset and placing pull request, and that one does not depend on this. Either can merge first. Both add lines to the same part of
AGENTS.md, so whichever merges second may need a one-line rebase, which I will do.Why
The reader from #434 loads the zone dataset from one fixed path in
.storage, and nothing puts a file there. This is the one path by which a download reaches it, and the way to take the file away again.What it does
Download (
async_download_zone_data). The caller gives the address, the SHA-256 it wants, and the hosts it allows. The module takes nothing the answering server says on trust:.partfile beside the target and are renamed into place. The.partfile is made new each time, private and exclusive, so a link, a named pipe or a stale file left at its path is never opened.Every failure raises
ZoneDataFetchErrorwith a reason a screen can show, and leaves the fixed path exactly as it was. A failure never repeats the address.A file placed by hand (
async_adopt_zone_data) goes through the same check before it is used.Removal (
async_remove_zone_data) deletes the file and any.partfile under the lock an install holds, so it cannot take half of one. It never raises. This is the removal you asked for in #434. The rule that calls it, when the last entry using the dataset is deleted, comes with the piece that knows which entries those are.One thing I need from you
Where the dataset will be published. I would suggest a release asset on this repository: the file
cap_alerts.nws_zones.jsonl.gzwith SHA-256c985ed4f…ee58, which your build reproduces. The module takes the address from its caller, so nothing in this pull request depends on your answer. The later piece that offers the download does, and it needs the address and the tag and file name you choose.GitHub serves a release asset through a redirect to another host. The caller has to allow that host, and I have not yet made a real download from GitHub.
How it was checked
pytest 2564 passed, 18 skipped; cov 98%; flow cov 100%; ruff check ok; ruff format ok; mypy ok..partfile remaining.Where this sits
It is the fifth of six pieces, sent early because it stands alone and because the address question is better asked now:
Refs NWS: area-scoped GPS/tracker mode that never sends coordinates (local point matching, multiple areas) #316