annie.dataset.filtering¶
Browse filtering (service): pure predicates over the manifest.
The Browse tab’s always-visible filter bar narrows the per-video manifest by
annotation coverage, review verdict, notes, annotator selection, label values, and
an explicit id list loaded from a CSV column. The logic lives here — independent of
NiceGUI and SQLite — so it is unit-tested directly: the UI supplies a
ReviewState per row (read from the store) and a FilterSpec built
from the controls.
Facets combine with AND; within a single label column the selected values combine with OR (e.g. Sentiment in {negative, neutral}).
Attributes¶
Tri-state presence facet (vdet, video frames, audio stream). |
|
Backwards-compatible alias for the vdet facet. |
|
any / none (0) / exactly one / multiple (2+). |
|
any / liked (good, the default) / disliked (bad). |
|
any / less-than-threshold / greater-than-threshold. |
|
Facets that only make sense when a vdet or track folder is a source. |
Classes¶
The per-video review state a filter needs, defaulted to "liked". |
|
A snapshot of the Browse filter bar. |
Functions¶
|
The source-dependent facets that fit the configured sources. |
|
Turn off every source-dependent facet not in |
|
Return whether a single video passes every active facet. |
|
Filter a manifest, keeping the entries that pass |
Module Contents¶
- annie.dataset.filtering.PresenceFilter¶
Tri-state presence facet (vdet, video frames, audio stream).
- annie.dataset.filtering.VdetFilter¶
Backwards-compatible alias for the vdet facet.
- annie.dataset.filtering.TrackFilter¶
any / none (0) / exactly one / multiple (2+).
- Type:
Track-count facet
- annie.dataset.filtering.ReviewFilter¶
any / liked (good, the default) / disliked (bad).
- Type:
Review facet
- annie.dataset.filtering.FramesFilter¶
any / less-than-threshold / greater-than-threshold.
- Type:
Frame-count facet
- class annie.dataset.filtering.ReviewState[source]¶
The per-video review state a filter needs, defaulted to “liked”.
Every video is liked (good) by default; a record only exists once the user interacts. Attributes mirror the persisted columns.
- verdict¶
"good"(liked, default) or"bad"(disliked).
- note¶
Free-text note (empty when none).
- in_annotator¶
Whether the video is queued for the Annotator tab.
- class annie.dataset.filtering.FilterSpec[source]¶
A snapshot of the Browse filter bar.
- name_prefix¶
keep only videos whose id starts with this (case-insensitive).
- video¶
video-file presence facet (rows from vdet/track files may have none).
- audio¶
audio-stream presence facet (ffprobe, cached as rows are viewed; see
audio_of). Rows not yet probed failhasandmissing.
- vdet¶
vdet-presence facet.
- tracks¶
track-count facet.
- frames¶
frame-count facet (uses the probed cache; see
frames_of).
- frames_threshold¶
the threshold for the
framesfacet.
- review¶
review-verdict facet.
- has_note¶
keep only videos with a non-empty note.
- in_annotator¶
keep only videos queued for the Annotator.
- labels¶
per-column allowed value sets (OR within a column, AND across).
- id_list¶
keep only videos whose id is in this set — the ids read from a CSV column (see
distinct_column_values()).Nonemeans the facet is off; an empty set is never set by the UI.
- id_source¶
the name of the CSV the
id_listcame from (for display).
- id_column¶
the CSV column the ids were read from (for display).
- property is_active: bool¶
Whether any facet is set (so the UI can show a “clear” affordance).
- annie.dataset.filtering.SOURCE_FACETS: tuple[str, ...] = ('video', 'vdet', 'tracks')¶
Facets that only make sense when a vdet or track folder is a source.
- annie.dataset.filtering.source_facets(*, has_vdet: bool, has_track: bool) set[str][source]¶
The source-dependent facets that fit the configured sources.
vdetneeds a vdet folder andtracksa track folder.video(does the video file exist) needs either: only vdet/track files can produce a row without a video.- Parameters:
has_vdet – Whether a vdet folder is configured.
has_track – Whether a track folder is configured.
- Returns:
The names (from
SOURCE_FACETS) to offer in the filter bar.
- annie.dataset.filtering.drop_facets(spec: FilterSpec, keep: set[str]) None[source]¶
Turn off every source-dependent facet not in
keep, so a hidden box never filters.- Parameters:
spec – The filter spec to update in place.
keep – The source-dependent facets still offered (see
source_facets()).
- annie.dataset.filtering.matches(entry, review: ReviewState, spec: FilterSpec, *, has_audio: bool | None = None, num_frames: int | None = None, label_of: collections.abc.Callable[[annie.core.models.VideoEntry, str], str | None] | None = None) bool[source]¶
Return whether a single video passes every active facet.
- Parameters:
entry – The
VideoEntryunder test.review – Its
ReviewState.spec – The current filter snapshot.
has_audio – The probed audio-presence flag (
Noneif not yet known).num_frames – The decoded frame count (
Noneif not yet known).label_of – Maps
(entry, column)to the (possibly transformed) label value; defaults to the entry’s raw label.
- Returns:
Trueif the video matches the filter,Falseotherwise.
- annie.dataset.filtering.apply_filters(entries: list, spec: FilterSpec, review_of: collections.abc.Callable[[str], ReviewState], audio_of: collections.abc.Callable[[str], bool | None] | None = None, frames_of: collections.abc.Callable[[str], int | None] | None = None, label_of: collections.abc.Callable[[annie.core.models.VideoEntry, str], str | None] | None = None) list[source]¶
Filter a manifest, keeping the entries that pass
spec.- Parameters:
entries – The per-video manifest.
spec – The current filter snapshot.
review_of – Maps a video key to its
ReviewState.audio_of – Maps a video key to its probed audio-presence flag (or
None).frames_of – Maps a video key to its decoded frame count (or
None).label_of – Maps
(entry, column)to its (possibly transformed) label value.
- Returns:
The entries that match, in their original order.