ursa.filters¶
Query-filter primitives for processed-store row-level filtering.
These live on :class:~ursa._query_types.UrsaQuery (time_filters /
metadata_filters) and are resolved at :meth:DataInterface.query time —
time_filters into recording-relative-second windows stamped onto
- attr:
QueryResult.time_selection,metadata_filtersinto row-level predicates applied during catalog resolution.
Units note: :class:IntervalSelector intervals are recording-relative
seconds (0 = recording start, same coordinate space as
ModalityRow.domain_intervals), whereas UrsaQuery.time_range is an
absolute epoch-nanosecond window across recordings. When both are set,
query() intersects them per recording.
Module Contents¶
Classes¶
Event-relative window selector — deferred (ENG-906). |
|
Explicit multi-window selector — N disjoint recording-relative-second intervals. |
|
Row-level predicate on modality (or recording) metadata / channel_spec. |
|
Base class for server-side temporal selectors ( |
API¶
- class ursa.filters.AroundEvent(/, **data: typing.Any)[source]¶
Bases:
ursa.filters.TimeFilterEvent-relative window selector — deferred (ENG-906).
A clean drop-in for the
time_filtersframework:AroundEventis accepted by the query surface, but resolution intotime_selectionis not yet implemented —query()raisesNotImplementedError(ENG-906)for it today (only the dispatch branch exists). Implementing it needs (1)EventRows populated for the recording and (2) the events-table join in_resolve_time_filters.Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- kind: Literal[around_event]¶
‘around_event’
- event_type: str¶
None
- before: float¶
0.0
- after: float¶
0.0
- class ursa.filters.IntervalSelector(/, **data: typing.Any)[source]¶
Bases:
ursa.filters.TimeFilterExplicit multi-window selector — N disjoint recording-relative-second intervals.
Event-independent: generalizes
time_rangeto a list of windows expressed in recording-relative seconds (so it applies per recording, unlike the absolute-nstime_range).query()tiles/clips to the selected intervals; :meth:DataInterface.streamlays its window grid within each interval independently (never across a gap).intervalsacceptsTimeWindowinstances or(start_s, end_s)tuples (coerced), e.g.IntervalSelector(intervals=[(0, 10), (20, 30)]).Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- kind: Literal[interval]¶
‘interval’
- intervals: list[ursa.catalog.schemas.TimeWindow]¶
‘Field(…)’
- class ursa.filters.MetadataFilter(/, **data: typing.Any)[source]¶
Bases:
pydantic.BaseModelRow-level predicate on modality (or recording) metadata / channel_spec.
Applied at
query()time after status/worker_ids routing and before the time-domain prune.fieldis a dotted path whose namespace depends ontarget. Fortarget="modality"(default) it reads the- Class:
ModalityRow’smetadata(e.g."device") or itschannel_spec(e.g."channel_spec.units"/"channel_spec.reference"— the channel count islen(channel_spec["names"]), there is non_channelskey). Fortarget="recording"it reads only the parent- Class:
RecordingRow’smetadata—channel_specis not available at recording scope, and a failing recording-level predicate drops all of that recording’s rows. There is deliberately no genericFilteralias — the name says metadata, sinceTimeFiltersubclasses are equally “filters”.
Missing-field convention: a field absent from the namespace fails all predicates except
exists(which returnsFalse). In particularop="ne"/op="contains"against a missing field drop the row rather than keeping it — mirroring SQL’sNULL != xbeing not-true. Useop="exists"if you need to test for presence.Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config¶
‘ConfigDict(…)’
- field: str¶
None
- op: Literal[eq, ne, gt, ge, lt, le, in, contains, exists]¶
None
- value: Any¶
None
- target: Literal[modality, recording]¶
‘modality’
- class ursa.filters.TimeFilter(/, **data: typing.Any)[source]¶
Bases:
pydantic.BaseModelBase class for server-side temporal selectors (
UrsaQuery.time_filters).Frozen so filters key dicts and round-trip through
UrsaQuery.query_hash. Concrete subclasses carry akinddiscriminator. Resolved byquery()into recording-relative-second windows on- Attr:
QueryResult.time_selection.
Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config¶
‘ConfigDict(…)’