* fix(bufr): ask one question about the reader, and answer it in one place
Read…ing 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.
Another guarded nothing: 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.
So: `bufr_is_available()` for the question and `require_bufr()` where the
answer has to come early. The refusal has a type, `BufrReaderMissingError`,
because the CLI turns it into a line of advice and must not turn every
import failure into one -- a cycle or a typo inside a provider module is a
defect and wants its traceback.
Both halves also answered by raising, which is what a question must not do.
`ensure_eccodes` caught `ModuleNotFoundError` where an eccodes with no
compiled library raises the plain `ImportError`; `ensure_pdbufr` re-raised
any `RuntimeError` whose text was not gribapi's present phrasing. The
second is asked while the suite is collecting, where a raise aborts
collection rather than skipping the tests that want a reader. And an
install that is present and broken says so, rather than being told to
install what it has.
The CLI reports all of it. `values`, `interpolate` and `summarize` caught
`ValueError`, which an ImportError is not, so the sentence naming the extra
arrived as the last line of a stack trace. They share one handler now,
covering the three failures a caller can act on rather than debug -- which
is also where the "No data available" check belongs, having been written
out three times.
The extras follow the same shape. pdbufr requires eccodes, so `bufr` and
`eccodes` were never independent and the docs said to install both. The
floor is the oldest release published as a wheel: 1.5.2 stood there and is
a 2023 source tarball, which the minimum-versions job -- resolving every
direct dependency to its floor, across extras -- had to build. Named in
both extras, since one lock covers every extra here but a consumer
installing `wetterdienst[bufr]` has no such luck. `pybufrkit` leaves it:
nothing in the library imports it, only the radar tests, which skip on it
now rather than failing to collect.
Split out of #1904, where all of this was found.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(tests): carry the fourth skip site across the split, and take the CLI test offline
Splitting this out of #1904 left the road test file behind, since it
belongs to that branch -- and it holds the fourth instance of the broken
skip this PR exists to remove. Worse: adding `require_bufr` to the road
values class makes that test *error* where it used to fail, because with
eccodes present and pdbufr absent it does not skip and now raises at the
request rather than at the import.
case old skips new skips
both present False False
eccodes only False True
So the skip comes along, which is where it was always going -- #1904
rewrites the rest of that file around it.
The new CLI test asked DWD for a road station on the way to the error. The
station list is downloaded before `.values` is touched, so offline or under
`-m "not remote"` it failed on the download and reported it as the message
being missing. It raises from a stubbed `get_values` now: this is a test
about what the CLI does with the error, and it needs no network to ask
that. 0.22s, and it fails when the handler drops the type.
And it asserted `"Traceback" not in result.output`, which cannot fail --
`CliRunner` keeps the exception on `result.exception` and never renders a
traceback into the output. It asserts the command chose to exit instead.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(bufr): let the probes answer whatever the import does
Both had been widened by naming what had been seen -- first
`ModuleNotFoundError`, then `ImportError`, then `RuntimeError` -- and an
`AttributeError` from `eccodes.eccodes` moving, or a gribapi error class
out of `codes_get_api_version`, would have escaped all three. That is the
same bug three times, and the list was never going to be complete: the
contract is that this question answers, so it catches anything and says
what happened.
It matters in two places that cannot take a raise, both of which this
branch already relies on: `_attach_bufr`, documented to log and carry on
rather than fail a radar query, and `BUFR_AVAILABLE`, computed while the
suite is collecting, where a raise ends the collection instead of skipping
the tests that want a reader.
And the two probes read a missing module's name differently -- one exactly,
one by prefix -- so `ModuleNotFoundError(name="eccodes.eccodes")`, which
means eccodes is present and broken, was a warning through one and silent
absence through the other. Silent absence is what hands the caller advice
to install what they already have, which the warning exists to avoid. Both
read it exactly now.
Neither is reachable with the eccodes in the lockfile or at the floor;
both are the hardening the docstring already promised.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BMmz23eRedUH9VTYaMQzV
* fix(cli): say it once when the window holds no readings
`core.get_values` logged "No data available for given constraints" and
handed the empty frame back, and the CLI logged the identical line again
before exiting -- so one empty result read as two, and with the library's
own info line on the way out of `.all()`, three at default verbosity.
Reporting it belongs to the caller, which is the only layer that knows what
it means: the CLI says it and exits 1, the REST API returns the empty
result. `get_values` keeps the early return -- there is nothing to
SQL-filter -- and drops the log.
Nothing is lost for the REST API or for library callers. `query()` skips a
station whose frame is empty rather than yielding it, so the list `all()`
concatenates is empty exactly when the result is, and the info line already
covers every empty outcome.
Verified on the real stack with only DWD's index and data files stubbed:
one record, INFO, from `wetterdienst.model.values`. The new test fails with
the removed line put back.
Also rewords a comment in `ensure_pdbufr` that read as if the sibling probe
matched by prefix. Neither does; both read the name exactly.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>