validate¶
Post-ingest invariants. Each is a single set-based query, so the whole set is
cheap enough to run in CI — gffbase validate --strict is the command-line
form.
The one that matters most is INV-5: a fused feature whose envelope is narrower
than its segments simply stops being returned by region(), with nothing
raised anywhere. Errors and warnings are separate, because an error is a
broken invariant while a warning is something legal but suspect.
Post-ingest invariants.
Schema v2 spreads one logical feature across two tables, and the interesting
failure mode is not a crash -- it is a database that answers every query
plausibly and wrongly. The worst case is INV-5: if a fused feature's envelope
is narrower than its segments, region() silently stops returning it. Nothing
raises, no count looks odd, and the feature is simply gone from results.
So these run automatically at the end of a strict-mode ingest, and can be run by hand at any time. Every check is a single set-based query returning a count plus a few examples, so validating a GENCODE-scale database is a handful of aggregate scans rather than a row-by-row walk.
Severity is not decoration. An error means the database will give wrong
answers; a warning means something is unusual but defensible in real data --
abutting segments, for instance, occur in files people actually ship.
Violation
dataclass
¶
One invariant that did not hold.
ValidationReport
dataclass
¶
ValidationReport(level: str, checked: list[str] = list(), violations: list[Violation] = list(), skipped: list[str] = list())
ValidationError ¶
Bases: AssertionError
A database violates an invariant that makes its answers wrong.
AssertionError rather than ValueError: this is never bad input from the
caller, it is gffbase having produced or been handed a database whose
internal structure contradicts itself.
validate_db ¶
validate_db(db, level: str = 'fast', *, raise_on_error: bool = False, sample: int = 200) -> ValidationReport
Check a database's structural invariants.
level="fast" runs every check that is a fixed number of aggregate scans.
level="full" adds INV-12, which re-parses stored attribute blobs for
sample features and is the only check whose cost grows with the corpus.
Checks that depend on structures a database does not have -- a v1 shim has
no segments -- are recorded as skipped rather than silently passing, so a
green report cannot mean "nothing was looked at".