* fix(dwd): read an empty road station group as empty, not as a broken frame
Th…e road stations report in fifteen-minute batches and four of the groups
are already known to go quiet, so a window with no file behind it -- or one
holding only the 142-byte empty files of GH-1526 -- is an ordinary outcome.
The frame standing for "nothing here" carries no columns, which is what the
rest of the library reads as "this station had nothing": `_process_dataset`
and `_collect_station_data` each guard on it, and one of them says so in a
comment. The road collector built such a frame and then filtered it for a
station id before asking whether it held anything, and a filter on a frame
with no columns is a lookup for a column that is not there. So the walk
raised `ColumnNotFoundError: unable to find column "station_id"; valid
columns: []` from its middle, where returning an empty result was meant.
This is what has failed `test_pdbufr_examples` on every CI job -- the one
deterministic red in an otherwise flaky matrix, which made the whole matrix
unreadable. The test passes locally, the data being there; the new test
does not need it to be, taking the upstream listing away instead. It raises
the exact CI error with the guard removed.
The example it runs no longer plots a comparison it does not have. One
series is not a comparison, and a line of text says more than an empty
plot -- which also keeps the example off a pandas-version question about
what plotting nothing does.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* refactor(bufr): ask one question about the BUFR reader, in one place
Reading BUFR takes two halves that fail apart: pdbufr, which reads the
messages, and eccodes, the binding to the library that decodes them. No
caller cares which is missing -- the only question is whether this
environment can read BUFR at all -- and the codebase asked it four
different ways.
One of the four was wrong. `not ensure_eccodes() and not ensure_pdbufr()`
skips only when *both* are missing, so with eccodes installed and pdbufr
not -- the one case the skip exists for -- the test ran and died on the
import. It stood over three tests, and I had just copied it onto a fourth.
Another guarded nothing at all: the road values class called
`ensure_pdbufr()` in `__post_init__` and discarded the bool, so a missing
reader surfaced as a bare ImportError out of the middle of a parse rather
than as an answer to the request. It raises there now, naming the extra to
install and where the compiled library comes from.
So: `bufr_is_available()` for the question and `require_bufr()` where the
answer has to come early, both in `util/eccodes.py`, whose docstring now
says why one half is never enough to ask about. Every caller and all four
skip conditions go through them.
The extras follow the same shape. pdbufr requires eccodes, so `bufr` and
`eccodes` were never independent, and the docs said to install both --
`bufr` names eccodes itself now and is the whole of what reading BUFR
takes. `pybufrkit` leaves it: nothing in the library imports it, only the
radar tests do, where it is already a dev dependency.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): guard the parse too, and read a library that will not load as absent
Five from the review, and the first is the same bug one level down.
Guarding the station group covered a group that published no file. A file
that publishes nothing is the other half: the empty ones are turned away by
their exact length, 142 bytes, which is a guess at a shape rather than a
reading of one, so one holding no subsets at any other length reached the
parse. There the merge of the two column batches raises `KeyError: 'year'`
and the select after it would have raised for `shortStationName` -- the
same failure the changelog had just claimed was fixed. A file may hold
nothing, and it comes back in the shape the files that hold something come
back in, so the two still concatenate.
`ensure_eccodes` caught `ModuleNotFoundError`, which is what a missing
package raises. An eccodes with no compiled library behind it is installed
and raises the plain `ImportError` out of the import instead, so the
question raised rather than answering -- from inside `_attach_bufr`, which
is documented to log and carry on rather than fail a query, and whose call
sits outside its own try.
The station-group test would have gone green with its fix taken out the day
A006 leaves the network: no station, no walk, and an empty frame to assert
on either way. It stands the station up now instead of looking it up, which
also takes the network and the reader out of a test about frame handling.
`require_bufr` has tests, the caching being the reason absence is staged
where it is looked up rather than at the two halves behind it. And a
plural left dangling in the radar docs by the rewrite.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): ask the second column batch whether it is empty too
The columns are read in two batches and only the first was asked. The
second comes back empty on its own terms -- a station reporting
temperatures and no wind at all answers the one read and not the other,
`read_bufr` emitting an observation only where every column asked for is
present -- and merging a frame with no columns is a join on a key that is
not there. `KeyError: 'year'`, out of the middle of the collection walk,
which is the failure the last commit said it had fixed.
Third time for this shape in one file: guard the group, guard the file,
guard the batch. Each was the same mistake read at a different depth --
a frame that stands for "nothing here" used before anyone asked whether
it held anything.
A file that is skipped now says so in the log. It used to be loud and
wrong; being quiet and right is better, but not so quiet that a file that
never appears in a result leaves no trace of having been passed over.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): keep a road station's reading where it arrives in parts
A road file holds one subset per station carrying the descriptors that
station has, and `read_bufr` emits an observation only where every column
asked for is present -- its default, and so ours. Asking for all fourteen
parameters of the dataset and keeping the complete ones threw away every
reading of anything not universally fitted. Against one file of the DD
group, through the provider's own parse:
before: 105 values, no roadSurfaceTemperature at all
after: 121 values, roadSurfaceTemperature for 16 of the 25 stations
Same stations, same rows, every other parameter identical to the value.
The road surface temperature, on a road weather network.
So the reads are required of the station and the minute, which every
subset carries, and the parts of one reading are folded back on those keys
-- `first` taking the value that is there over the ones that are not. Two
things follow from reading it that way and both are handled here: a
descriptor no subset in the file carries is not a column at all, where the
select that follows asks for every parameter by name, so it is filled in
as null; and the two batches are joined outer rather than inner, so a
station that answered one read and not the other keeps what it did say.
Folding it into this PR rather than leaving it for another, as asked.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): skip the merge, not the file, when the second batch says nothing
The guard on the second read was written when both reads were strict and
so came back empty together: returning an empty frame said "this file has
nothing", and it was true. It stopped being true two commits later. The
reads are required only of the station and the minute now, and the merge
is outer precisely so a partial answer survives -- so a group of stations
reporting temperatures and no wind at all answers the first read, and the
guard threw every one of those temperatures away to avoid joining on a
column that was not there.
Skip the merge instead. The null fill below supplies the columns the
second read would have brought, which is what it is for.
The comment on that branch described the very case it mishandled, and the
test asserted the empty frame -- locking the loss in and calling it
correct. It asserts the readings now, and fails with the return put back.
And the one new parse test without the reader guard has it: it stubs
`pdbufr.read_bufr` by name, so without pdbufr installed it errored where
it meant to skip -- which is the failure this PR fixed in the skip
conditions, arriving by another door.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* test(dwd): guard the last unguarded test, and quote one measurement
The fold test stubs `pdbufr.read_bufr` by a string target, which imports
pdbufr during setup, so without a working compiled eccodes it errors where
it means to skip. Last round's fix put the guard on its two siblings and
missed it -- and I reported all five as guarded on the strength of
`grep -c` returning 5, which counted the pre-existing test among them. A
count is not a check; the tests are walked by name now to say so.
And the evidence was quoted twice over from two different measurements:
the docstring of `_read_batch` gave the first batch alone, 70 of 86, where
the changelog gave the whole parse, 105 of 121. Both were true of what
they measured and neither said which, so a reader reconciling them found
two accounts of one file. All three places quote the parse now.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* refactor(dwd): make having nothing to answer with one shape
Three shapes stood for it: no columns where the group published no file,
five where the files it published held nothing, and the seven a reading
has. The comment justifying the early return said the caller reads a frame
with no columns as "this station had nothing" -- true of the first shape
and false of the second, which this branch introduced. It is harmless only
because every caller happens to ask `is_empty()` before touching a column.
A frame of no readings carries the columns a reading does now, from every
path out of the parse. So the filter has a station id to look for and the
select has columns to name, and the early return goes: one line answers for
the empty case and the populated one alike.
Which is the fix for the thing that went wrong four times in this file. A
guard is a place to forget a guard, and each one I added was a new place to
forget the next. Not handing a frame on until it has the shape the caller
expects means there is nothing left to remember.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* refactor(dwd): let a read that finds nothing carry its columns back
The two batch guards were asymmetric -- an empty first batch abandoned the
file, an empty second only skipped the merge -- and the asymmetry was
harmless only by accident. Required of the keys alone, `read_bufr` returns
key-only rows for every subset, so an empty batch means the file decoded to
no subsets at all, and both branches meant the same thing. The comment on
the second described a case its own `required_columns` cannot produce: a
station reporting temperatures and no wind answers both reads, one of them
with nulls. Only the mock in its test ever reached it.
So the read carries its columns back when it finds nothing, and neither
caller needs a branch. That is the same move as the last commit, one level
down: a shape rather than a special case, and two fewer places to forget a
guard. Verified against a real file -- 121 values, roadSurfaceTemperature
recovered, unchanged by the restructure -- and the empty read is
load-bearing, the tests failing with `KeyError: 'year'` when it is undone.
Three messages that said something other than what they meant:
`require_bufr` read as though the `bufr` extra carries the compiled
library. It does not, which is the whole reason the system packages are
named; a user with a missing libeccodes.so was being told to retry what had
already failed.
The fold's docstring promised `first` takes "the value that is there over
the ones that are not", which is not what it does when two subsets both
have one. Across twenty DD files there is no such pair -- the subsets of a
station divide its descriptors rather than repeating them -- so the
docstring says that, and says what would have to be decided first if one
ever did.
And the example claimed no overlapping readings where it had only tested
whether either series was empty. It names the one that is missing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): state the invariant the fold actually rests on, and skip on pybufrkit
The docstring said the subsets of a station divide its descriptors rather
than repeating them. They repeat them constantly. Measured over 25 files of
the DD group: 1296 descriptors carried by more than one subset of the same
station and minute, and in none of them did the subsets disagree about the
value. That agreement is what makes taking the first one safe, and it is a
weaker and different claim than the one I wrote -- a maintainer trusting
the old wording would read a second non-null value as a second sensor,
which is exactly backwards.
I took that claim from a review summary and repeated it without measuring
it. The number in a docstring should come from a measurement the person
writing it ran.
Taking pybufrkit out of the `bufr` extra left the radar BUFR tests
importing it unconditionally from `radarplus`. An environment with `bufr`
and `radar` but not `radarplus` used to get it from `bufr`; it would now
fail at collection rather than skipping with the rest of that module, which
is guarded for h5py and wradlib already. CI installs `radarplus`, so only a
contributor would have met it.
The file that decodes to nothing logs at INFO, as its neighbour does for a
group that published no file at all -- the changelog said it says so, and
DEBUG is not where anyone would find it.
And the empty placeholder carries the key dtypes rather than leaning on
pandas reading an all-empty object column as dtype "empty" and letting it
merge against int64 keys. That is a leniency, not a promise.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(deps): stop naming eccodes where naming it downgrades it
Adding `eccodes` to the `bufr` extra was cosmetic -- pdbufr requires it, so
it arrives either way -- and it made eccodes a direct dependency for the
first time. The minimum-versions job resolves every direct dependency to
its floor, so it now picks up what that floor names:
eccodes as a direct dependency: 1.5.2 (2023, source tarball, no wheel)
eccodes left to pdbufr: 2.48.0 (current, wheels)
Forty-seven minor versions, in the one job that carries
`continue-on-error: true`. Whatever that would have broken, it would have
broken without saying so -- which is the thing this branch exists to stop
CI doing. The extra is still the whole of what reading BUFR takes; the
comment says why the second half must not be named to arrive.
Two stale pieces of prose, both mine. The test for a file that answers one
read and not the other still described skipping the merge, which two
commits removed -- a maintainer reading the test as the spec would look for
a branch that is not there and could put back the data loss the shaped read
took out. And "1296 of the 625 station/minute groups' descriptors" read as
a ratio of two things that are not comparable; it is 1296 descriptors
spread over 625 groups.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(deps): give eccodes a floor that exists as a wheel
Last round I took eccodes out of the `bufr` extra and wrote that this stops
the minimum-versions job resolving it down to 1.5.2. It does not. uv
resolves one lock across every extra, so the `eccodes` extra's own floor
binds whether or not that extra is the one installed -- and it still said
1.5.2. Measured on this branch:
as it stood: Update eccodes v2.47.0 -> v1.5.2
with the eccodes extra removed: Update eccodes v2.47.0 -> v2.48.0
So the comment and the changelog paragraph explaining the fix described
something the resolver does not do -- load-bearing documentation that was
false, which is the thing two of the last three rounds were spent removing,
and which I wrote while removing it.
The floor was never real to begin with: 1.5.2 is a 2023 source tarball with
no wheel on PyPI. It is 2.39.1 now, the oldest release with wheels for
every Python this project supports, verified to install and answer
`codes_get_api_version()` with a pdbufr that takes `required_columns`. The
job resolves to it rather than to a build:
Update eccodes v2.47.0 -> v2.39.1
eccodes stays unnamed in `bufr` -- pdbufr brings it, so naming it says
nothing -- but for that reason and not the one I gave.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(deps): name the eccodes floor where a consumer will meet it
The floor only bound inside this repository. uv resolves one lock across
every extra, so the `eccodes` extra held it here -- but the published
metadata for `bufr` names pdbufr alone, and pdbufr asks for eccodes at any
version. `pip install "wetterdienst[bufr]" "eccodes==1.5.2"` resolves
cleanly and installs the 2023 source tarball the floor exists to keep out,
and no doc mentions the `eccodes` extra any more, both pages having been
changed to say `bufr` alone. So the floor is named in both, and the comment
says why one is not enough.
And the docstring that described skipping the merge, which I reported fixed
last round and did not fix: the edit was the third in a script that raised
on the second, so it never ran, and I said it was done without looking.
Every edit in this commit asserts its own result.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): say when a second road sensor's reading is dropped
The docstring said the subsets of a station never disagree, and gave that
as what makes taking the first one safe. It is true of the DD group, which
is the only group I measured -- twice, having already been caught once for
generalising from a review's summary instead of from data. Across the last
five files of each:
DD 261 repeated descriptors, 0 disagreeing
FN 270 repeated descriptors, 54 disagreeing
HV 425 repeated descriptors, 56 disagreeing
Nor is it rounding. Station P129 reports roadSurfaceTemperature as both
281.55 K and 304.65 K -- 8 degrees and 31 -- and roadSurfaceCondition, a
code table, comes back as both 0 and 2, which is a difference in kind.
Two road sensors on one station are two readings, and this frame has one
row per station, minute and parameter to put them in. Which one is kept is
arbitrary and was arbitrary before, the old inner merge's cross product
being collapsed the same way a step later by `unique`. What changes is that
it is said: the parameters that disagreed are named in a warning, against
the file that held them. On a live HV file that reads
reports roadSurfaceCondition, roadSurfaceTemperature more than once for
one station and minute, with different values; keeping the first of each
Telling the sensors apart is a question about the shape of the result, not
about this fold -- the station index carries `road_sector`, so there is
something to name them by if it is worth naming.
And the test workflow watches `examples/**` now. `tests/examples` runs
those files, and this branch changes one; a pull request touching only an
example did not run the test that executes it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* docs(dwd): correct what could name a second road sensor, and point at GH-1908
The docstring said the station index carries `road_sector`, so there is
something to name the sensors by. There is not. The index has one row per
station -- E130 is road_sector 923, once -- so it says where the station
stands, not which of its sensors spoke. I wrote that as an aside without
checking it, and then repeated it.
Looking properly, nothing obvious names them. `positionOfRoadSensors` is
in the BUFR and reads 0 for both subsets of every conflicting station I
checked. `subsetNumber` comes back as the whole file's numbering rather
than the row's. So finding a discriminator is the first part of the
problem and not the easy part, which is what GH-1908 is for.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): say the sensor conflict once at info, and skip a quiet group cleanly
The disagreement was logged at warning, once per file and per batch. Some
groups trip it on every file, and a full-history road request walks around
193 of them -- so a routine query would print a few hundred warnings about
a condition the code has already decided it cannot do anything about until
GH-1908, which the message now names. Info, where the sibling "holds no
reading" line already is.
The two passes it took share one groupby now. The `nunique` pass exists
only to write that sentence, so it should at least not group twice.
And two comments had been spliced into one block, the second starting
mid-sentence where its opening had gone -- it reads as a continuation of
the two-sensors paragraph above it and is about the line below.
The one remote road test asserted `-40 <= min() <= 40` on a frame that may
be empty, and polars gives `None` for the minimum of nothing, so a quiet
station group failed it with a TypeError about int and NoneType. A group
going quiet is this branch's whole premise -- four are listed in the module
as known to do it -- so the one test that talks to the network now skips on
it and says which case it met.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): make the empty excuse prove itself, and stop catching everything
The skip I added last round to stop a quiet group failing with a TypeError
also made the one end-to-end road test unable to fail for the thing this
branch is about. A parse that returns nothing for every station -- a bad
`required_columns`, a broken merge, a wrong filter -- came back empty, and
the test skipped and CI went green. So the excuse has to be visible
upstream before it is accepted: if the group published files and none of
them parsed, that is the regression, not a quiet group. Pointing the
station filter at a station that does not exist now gives
AssertionError: group KK published 193 files and none of them parsed
where it used to skip.
`except ValueError` was written for `pl.concat` on an empty list, which
cannot happen any more -- the empty case is a shape now. What was left
caught anything else the download or the parse might raise and reported it
to the caller as "this station had nothing", which is the ambiguity the
rest of this branch exists to remove. Gone.
The second-sensor line named the file and not the stations. `first` is
taken per column, so a row of a station that reports twice can hold one
sensor's air temperature beside the other's road surface temperature -- a
reading no sensor took -- and naming the stations is what lets a caller
find those rows instead of learning only that some exist.
And the eccodes floor is 1.7.1, the oldest release published as a wheel,
rather than 2.39.1. Keeping the minimum-versions job off a 2023 sdist does
not need a major bump: `ensure_eccodes` asks for `codes_get_api_version`,
which 1.x has, and I checked 1.7.1 answers it beside the pdbufr floor. An
install pinned to eccodes 1.x keeps resolving, which my number would have
broken for no reason I could have defended.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(tests): read the listing for files, and give coverage the same inputs
The guard I added last round asserts that a group published nothing before
accepting an empty result as a quiet group. It reads the listing for
length, and a group directory that exists and holds nothing does not list
as nothing -- it lists as itself:
KK n= 193 first=…/KK/swis2-ISXD70_DWKK_121945-2609121945-SH---bin
HS n= 1 first=…/road_weather_stations/HS/
DF n= 0 first=None
Seven groups are in HS's state today. So the day KK goes quiet the same
way, the test would have failed with "published 1 files and none of them
parsed" -- the misleading failure the guard exists to prevent, arriving by
its own hand. It reads the listing for files now, by the timestamp the file
index reads them by, and the three cases sort correctly: a quiet group and
a removed group skip, a group with files fails.
That is the second time I have asserted what an API returns for the empty
case instead of asking it. The first was uv resolving across extras.
`tests.yml` gained `examples/**` last round and `coverage.yml` did not,
though it runs the same suite and its header says it takes the same inputs
as the test matrix. A pull request touching only an example ran the matrix
and skipped coverage, and the comment claiming otherwise made that harder
to notice.
And the second-sensor line said a descriptor is reported "more than once",
where what it checks is more than one *value*: repeats that agree are
folded silently and never named, which is the whole point of the fold.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): a listing entry is a file when it carries a timestamp, in the library too
The test added two rounds ago filters the listing by `DATE_REGEX`, because
a group that exists and holds nothing lists as itself rather than as
nothing. The library did not, so that knowledge lived in the test and not
where it is needed: the directory made `files` non-empty, `No files found`
never fired, and a request without dates -- where nothing filters on the
timestamp afterwards -- downloaded the directory and handed it to the
reader as a BUFR message:
INFO Downloading …/road_weather_stations/HS
INFO …/road_weather_stations/HS holds no reading for ['relativeHumidity', …]
Now:
INFO No files found for HS.
Seven groups are in that state today. It degraded to an empty result
either way, so nothing was wrong with the answer -- only with the download,
and with a log line that said the opposite of what had happened.
And `ensure_pdbufr` re-raised any `RuntimeError` whose text was not
"Cannot find the ecCodes library". That is gribapi's present wording and no
promise, and this is the other half of the bug fixed earlier in this branch
for `ensure_eccodes`: the question is asked from `_attach_bufr`, documented
to log and carry on rather than fail a query, and from the `BUFR_AVAILABLE`
the suite computes while collecting -- where a raise aborts collection
rather than skipping the tests that want a reader. Any RuntimeError out of
that import is an answer.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* test(dwd): tell a quiet station from a parse that returns nothing
The guard asked whether the *group* published files, then asserted on a
frame filtered to one station. A station going quiet while its group
reports is ordinary -- the guard's own comment says so -- and would have
failed with "group KK published 192 files and none of them parsed", which
describes something else entirely.
My first fix for that asked the whole group instead and dropped the listing
check, which turned a false failure into a false skip: break the parse for
every station and the group comes back empty too, so the test decided the
group was quiet and skipped the regression it exists to catch. Worse than
what it replaced.
Both questions are needed, and they separate the three cases:
nothing published -> skip
published, group parses none -> FAIL
published, group parses, this station quiet -> skip
Each simulated rather than reasoned about. Breaking the parse for everyone:
"group KK published 192 files and none of them parsed for any of its 63
stations". Emptying A006 alone: "group KK parsed, but station A006 is
quiet".
And the stub file in the empty-shape test was named `a-file-holding-nothing`,
which carries no timestamp -- so the file index I taught to drop such
entries last commit removed it, and only a `download_files` stub that
ignores its urls kept the case alive. It has a real name now, so the case
reaches the parse the way the listing would take it there.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* test(dwd): ask three neighbours, not sixty-three, and drop the notice to debug
The group fallback re-requested every station of the group, and the
collector reads all of the group's files for any one of them -- so 63
stations is 63 passes over the same 193 files, minutes of it, in ten matrix
jobs, on the path this branch expects to be common. Three neighbours answer
the same question.
Fixing that, I first turned the "nothing parsed" case into a skip and threw
away the regression detection again -- the third time on this guard. The
case it was reaching for is real, though: a listing says which entries are
files, not which hold readings, and a window of nothing but the 142-byte
empty files of GH-1526 would have failed loudly. The collector drops those
by size, so the test now asks the same question of the same files, and the
four cases separate:
nothing published -> skip
published, all of them empty -> skip
published, real files, nobody parses -> FAIL
published, real files, this station quiet -> skip
The failure case verified by breaking the parse: "group KK published 192
files with content in them and none of them parsed for any of 4 stations".
And the second-sensor notice is at debug. I moved it to info last round to
stop it being a wall of warnings, which it was, and info is the level the
CLI prints by default -- so a month of road data is a few thousand of them
either way. What the fold does belongs in the docstring and in GH-1908,
where someone would look; the line is for the run where they want to know
which stations and when. The test pins the level now: it asserted only on
the text, and `caplog.at_level(DEBUG)` captures info too, so it passed
without the change it was meant to cover.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(cli): report a missing optional reader instead of raising it
From Copilot's review. `require_bufr` raises `ImportError` at the request,
and the CLI catches `ValueError` -- which an ImportError is not -- so the
message naming the extra to install, the whole point of raising it early,
reached the user as the last line of a stack trace:
ImportError: DWD road weather data is published as BUFR, which needs
eccodes and pdbufr to read: `pip install wetterdienst[bufr]` installs both…
Now it is printed and the command exits 1, with no traceback. Verified by
simulating a machine without the reader.
All three commands that collect values needed it -- road is interpolatable,
so `interpolate` and `summarize` reach the same raise -- and adding a third
`except` to each pushed two of them past the complexity limit, which was
the right complaint. They share `_collect_or_exit` now: one place that
knows which failures a caller can act on rather than debug, which is also
where the "No data available" check belongs and was already triplicated.
Copilot's seven other comments were written against an earlier commit and
no longer apply: the batch guards it describes are gone, every parse test
carries the reader guard, the empty placeholder carries the key dtypes the
merge needs, and the stub filename carries a timestamp. I checked each
against the current code rather than the diff it reviewed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(bufr): say why a reader that is there does not work, and refuse in its own kind
Three from the review, all of my own recent making.
Broadening the catch in `ensure_pdbufr` was right and left the reason
nowhere: an installed reader whose compiled library is missing or mismatched
went to debug, and `require_bufr` then told the caller to install what they
already have. "Install the extra" is the whole story for a reader that is
absent and no help at all for one that is present and broken, and the advice
cannot tell those apart -- so the two cases are told apart here instead.
ModuleNotFoundError is absence and stays quiet, since the message covers it;
anything else is installed-and-broken and the loader's own words go out at
warning. `ensure_eccodes` was worse and is fixed the same way: it returned
False and said nothing at all.
Catching bare `ImportError` at the CLI covered every import failure raised
anywhere under the getters, not only the deliberate refusal -- so a cycle or
a typo inside a provider module would have printed one line and exited 1,
and the bug report from that run would carry nothing locatable. The refusal
has a type now, `BufrReaderMissingError`, an ImportError because that is
what it is.
And the guard that decides whether an empty result is a quiet station asked
four stations for one parameter. A road station may report a surface
temperature and no air temperature, so four of them lacking that sensor
would have failed CI with "none of them parsed" and no regression behind it.
It asks eight for the whole dataset: did anything at all come out of these
files.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): one rule for what a file is, and stop the remote test guessing
Four from the review. Three are small and the fourth is the same guard for
the fourth time, which is the answer to it.
`DATE_REGEX` admits a digit run longer than ten and `%y%m%d%H%M` does not,
so a listing entry that matched but would not parse raised
`InvalidOperationError` out of the file index and took the request with it,
where an entry that never matched was quietly dropped. Two rules for one
question. Not strict now: both become null and both are dropped.
The disagreement count ran per file and per batch whether or not anything
would be logged -- a groupby costing about a tenth of the read, to build a
debug line the CLI does not print. Asked only when it will be said.
And absence was read too widely: `import eccodes` on a broken install
raises `ModuleNotFoundError: No module named 'gribapi.bindings'` from
*inside* the package, which is not the package being absent, and taking it
for absence hands the caller advice to install what they already have --
the case the warning added last round exists for. The name distinguishes
them; an error carrying no name keeps the quiet path, there being nothing
to go on.
The remote test's guard is gone. Four rewrites each traded one wrong answer
for another -- failing on a quiet group, skipping a real regression,
failing on a station without an air-temperature sensor -- because it was
asking the network to say what it ought to have sent. The regression it was
chasing is a parse that returns nothing for the station asked for, and that
is a question about data, so it is asked of data:
`test_dwd_road_weather_keeps_the_station_that_was_asked_for` puts two
stations in a file and asserts the one asked for comes back. It fails when
the filter is broken, offline, in every environment. The remote test skips
when nothing was published and checks the range when something was, which
is all it can honestly do.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): match the stamp the format reads, and keep a canary on real bytes
`strict=False` stopped the crash and left the greedy pattern behind it, so
"matched but unreadable" became "not a file" silently. Two ways that bites,
both real: a longer digit run elsewhere in a name is captured instead of
the stamp beside it, and if the stamp ever gets longer every file in every
group nulls out at once -- an empty result behind a line saying no files
were found. It matches exactly the ten digits `%y%m%d%H%M` reads now, and
a listing whose entries carry no timestamp at all says so at warning
rather than passing for an empty group.
Removing the remote guard last commit left nothing failing when a real
decode returns nothing for anyone: the tests around it stub `read_bufr`, so
a pdbufr or eccodes change that empties every read would leave them green.
That is a question about live data which does not need guessing at what
upstream ought to have sent -- here is a file it did send, with bytes in
it, does it decode -- so it is asked that way. A window with nothing
published skips; a file with content that yields no readings fails:
AssertionError: …/DD/swis2-ISXD70_DWDD_150630-2609150630-DD---bin holds
2777 bytes and decoded to no readings
It catches a read that returns nothing. A change that still returns rows
and means something different by them is beyond it, and is what the folding
tests are for.
And an absent eccodes surfaces from `import pdbufr` as well, which the
previous commit classified as a broken install -- a warning and a traceback
for the one case `require_bufr`'s advice does cover.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* docs(dwd): say what strict=False is for now that the pattern is narrower
The comment explained `strict=False` by the pattern admitting a run longer
than ten digits, which it did when the comment was written and does not
since the pattern was narrowed to exactly ten. What is left is the real
reason: ten digits are not necessarily a date. `2699999999` matches and
will not parse, and strict parsing would take the request down over a name
that is not a file.
Found by Copilot, which is the second time it has caught a comment that
stopped being true one commit after it was written.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(dwd): tell a quiet road group from a rename, and stop the canary going quiet
The warning about names having moved fired on the case its own comment calls
expected. It reads "the group listing itself is one such entry and is
expected; a listing full of them is not" -- and then tested `if listed:`,
which is true at one. A group that goes quiet while its `LATEST` alias
outlives the last timestamped file it pointed at lists exactly that one
entry, so every poll of it would report a rename upstream instead of saying
no files were found. Counted above one now, as the comment always said.
Not reachable today -- DF and XX list zero entries, so the info branch still
wins -- which is why it needs a test rather than a sighting. Three listings:
none, one that is no file, two that are no files.
And the real-bytes canary skipped when the DD listing came back empty, which
is a listing that did not arrive rather than a group with nothing to say: DD
publishes every quarter hour. Skipping there is the one way this test can
stop testing anything while the suite stays green, and the remote test above
it now skips on an empty window too, so both guards for the decode path
could go quiet at once. An empty listing still skips, saying upstream was
not reached; a listing that arrives carrying no file now fails, because that
is the rename the canary is for.
14 passed against live DWD, the canary among them.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(dwd): say when a road name cannot be read, once per file, and only where it is bound
Three from a second review of this branch.
**A partial rename was silent.** The warning only fired when the listing
came back holding no file at all, and `strict=False` drops a name that will
not parse as quietly as one that never matched -- so a group publishing
under two families, as FN does under `DWFN` and `DWNB`, would lose half its
readings to a rename of one of them with nothing said anywhere: the frame
stays non-empty, so neither the warning nor the "no files found" line runs.
Counting the drops cannot tell the two apart -- the expected count is 1 for
DD and 2 for FN -- so it asks what the names are instead. Two are dropped as
a matter of course, the group listing itself and each family's `LATEST`
alias; a name that is neither is one the index cannot read, whether or not
files were found beside it.
Checked against all 26 groups live: no warning, 4090 files across the
populated ones. The first cut warned on seven quiet groups, because the
listing names the group directory entry after the group -- `HS`, not the
empty string -- which is what asking upstream rather than reasoning about it
is for.
**A file that decodes to nothing said so twice.** Once per batch, each
naming its descriptors, at the level the CLI logs by default -- and both
batches are read with the same `required_columns`, so they always agree. The
caller says it once, naming the file.
**`counts` was read outside the gate that binds it.** Safe only because
`disagreeing` was `[]` otherwise; any edit giving it a value elsewhere turns
the line into a `NameError` that waits for the first station that disagrees,
on a path no test without debug logging runs. The whole block sits inside
the gate now.
18 passed offline, and with remote against live DWD.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* docs(changelog): state what ships, once, rather than how it got there
Three entries in the unreleased section described states that never shipped.
The file index had two entries with all but the same headline, one of which
stated a rule and then corrected it two clauses later -- the leftovers of
amending a sentence twice rather than rewriting it. They are one entry now,
saying what the rule is: a listing entry is a file when it carries the
timestamp the index reads it by, two kinds of entry never do and are
dropped, and a name that is neither is said out loud.
The two probe entries described successive states of one `except` clause,
so a reader of the release would have got the development history instead of
the change. One entry now, and it names the holes correctly -- checked
against the code as it stood rather than written from memory: `ensure_eccodes`
caught `ModuleNotFoundError` and `RuntimeError` but not the plain
`ImportError`, while `ensure_pdbufr` caught `ImportError` and re-raised a
`RuntimeError` unless its message matched gribapi's wording. A first draft of
this entry said only `ModuleNotFoundError` was caught, which was wrong about
both.
And "all four call sites ask `bufr_is_available` now" counted the old
spellings, not the new sites. There are three: `bufr_is_available`,
`require_bufr`, and one `BUFR_AVAILABLE` the tests share.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>