BE: add 'in' operator to MetadataFilter for categorical filtering - #1745
Conversation
Adds weather (skewed string), reviewed (boolean), camera_id (25 values, exercises the "Other" bucket), and split (~20% missing, exercises the "Missing" bucket) alongside the existing numeric fields. location now uses weighted sampling instead of uniform. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughChangesMetadata filtering
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant APIClient
participant MetadataValueCountsAPI
participant MetadataFilter
participant apply_metadata_filters
participant PostgreSQL
APIClient->>MetadataValueCountsAPI: submit metadata/value-counts request
MetadataValueCountsAPI->>MetadataFilter: validate filter
MetadataValueCountsAPI->>apply_metadata_filters: apply validated filters
apply_metadata_filters->>PostgreSQL: execute IN or NULL predicate
PostgreSQL-->>MetadataValueCountsAPI: return matching rows
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ Fast Track: checks did not pass
To run the guardrails locally, from Reflects |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55ec580ab7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ta-bar-chart-filter-ui-8-sp.p0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds an 'in' operator that accepts a list of string/boolean/null values and builds an OR predicate, using a LEFT OUTER JOIN when null is present to match samples with no metadata entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55ec580 to
cf40cb2
Compare
ebfc8d8 to
1a22eff
Compare
|
/review |
Split the combined test into focused cases for string values vs booleans, use keyword arguments for clarity, and tighten resolver call assertions with assert_called_once_with. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a function and its module file share the same name, mypy resolves the attribute as the module (not callable). Add a __init__.pyi stub for metadata_resolver to declare the four exported functions explicitly, and use explicit re-exports (as) in both __init__.py files to signal intent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ta-bar-chart-filter-ui-8-sp.p0
…ta-bar-chart-filter-ui-8-sp.p0
…ta-bar-chart-filter-ui-8-sp.p0
Removed section on AI Team Workflow and unnecessary blank lines.
- Assert collection_id is forwarded to the resolver in the route test - Use keyword arguments in all _create_sample calls - Reduce other_collection seed to 1 sample (sufficient to prove isolation) - Add active.other_count assertion to complete the boolean field checks - Add docstrings to clarify own-key-exclusion filter semantics, known-fields behaviour under a no-match filter, and the literal-key test purpose Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t-filter-ui-8-sp.p2' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p4
…t-filter-ui-8-sp.p0' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p1
…t-filter-ui-8-sp.p1' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p1.p2
…ta-bar-chart-filter-ui-8-sp.p1.p2
…t-filter-ui-8-sp.p1.p2' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p1.p3
- Remove redundant response_model from route decorator - Make request body required (filters nullable inside the model) - Expand docstring with top-20 cap, other_count, missing_count, and faceted-search semantics Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…t-filter-ui-8-sp.p1.p3' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p2
…ta-bar-chart-filter-ui-8-sp.p1.p2
…t-filter-ui-8-sp.p1.p2' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p2
…ta-bar-chart-filter-ui-8-sp.p1.p2
…t-filter-ui-8-sp.p1.p2' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p2
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…t-filter-ui-8-sp.p1.p2' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p2
…t-filter-ui-8-sp.p2' into kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p4
…ta-bar-chart-filter-ui-8-sp.p4
Summary
Stacked on p3.
Adds an
inoperator toMetadataFilterso the frontend can request samples matching any of a set of categorical values (including null/missing):str, allbool, or[None]/[str | None])ORpredicate via a standard SQLINclause for non-null valuesNoneis included, uses aLEFT OUTER JOINso samples with no metadata entry for the field are also matchedAlso includes a mypy
# type: ignore[no-untyped-call]fix forquery.compile(dialect=postgresql.dialect())intest_metadata_filter.py, matching the pattern used in other test files.Test plan
make static-checkspassesmake test-cipasses (new tests intest_metadata_filter.pyandtest_sample_metadata_filtering.py, plus additional API tests intest_metadata.py)Part of LIG-9585.
Summary by CodeRabbit
New Features
inoperator.infilter lists now return a validation error.Tests