Skip to content

API Reference parrot.tools.dataset_manager.filtering.contracts

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.dataset_manager.filtering.contracts

View source

Pure Pydantic contracts for common-field filtering (FEAT-225 Module 1).

These are I/O-free data models. They carry no driver, DSN, or SQL information — the FilterCompiler and DatasetManager methods consume them.

Note: from __future__ import annotations is intentionally omitted here to ensure Pydantic v2 can resolve Literal annotations at class definition time without requiring a manual model_rebuild() call.

Class FilterCondition

A single applied condition within a filter request.

Fields:

Field Type Default Description
op FilterOp The filter operator to apply.
value Any None The operand — scalar, list, {"min": ..., "max": ...} dict for range, or radius specification for radius.

Class FilterDefinition

A declarative common-field filter definition stored on a DatasetManager.

Instances are validated at define_filters() time, before any I/O. The model_validator enforces op⇄kind compatibility.

Fields:

Field Type Default Description
name str Stable filter identifier used in requests and the schema.
columns List[str] Column(s) targeted; spatial filters may carry [lat, lng] or a single geometry column.
kind FilterKind Semantic kind of the filter (categorical, numeric, temporal, text, or spatial).
ops List[FilterOp] Allowed filter operators for this definition (at least one).
required bool False When True, apply_filters raises ValueError if a target dataset lacks the column(s). When False (default), missing-column datasets are silently skipped.
values_source Optional[ValuesSource] None Optional explicit source for distinct values.
label Optional[str] None Human-readable label for frontend display.
description Optional[str] None Longer description for documentation or LLM context.

Attribute FilterKind

Attribute FilterOp

Class FilterResult

Records the per-run outcome of DatasetManager.apply_filters.

Fields:

Field Type Default Description
applied List[str] Names of datasets that were successfully filtered.
skipped List[str] Names of datasets that were skipped entirely because they lack ALL target columns and the filter's required flag is False.
partial_skips Dict[str, List[str]] Per-dataset mapping of filter names that were skipped for that dataset because the target column was absent (but the filter was not required). A dataset may appear in both applied (at least one filter matched) and partial_skips (at least one other filter was skipped). Example:: { "stores": ["temperature"], # temperature col absent }

Class ValuesSource

Specifies where to obtain the distinct values for a frontend combo.

At most one of query_slug, column, or dataset is typically provided. All are optional; when present they are used by DatasetManager.get_filter_values to locate the value list.

Fields:

Field Type Default Description
query_slug Optional[str] None Named query slug whose result set provides the values.
column Optional[str] None Column name to run a DISTINCT query against.
dataset Optional[str] None Restrict value inference to a single named dataset.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally