feat(auditor): add filtering to target and config list endpoints (AIRCORE-387)#182
feat(auditor): add filtering to target and config list endpoints (AIRCORE-387)#182maxdubrinsky wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds query filtering to the targets and configs list endpoints. New filter schemas define optional fields for type, model, description, project, and timestamp ranges. A dependency factory validates filter payloads and converts Pydantic errors to HTTP 422. Both endpoints inject filter dependencies, forward converted filter objects to the entity client, and echo filters in responses. Tests verify parameter forwarding, range parsing, validation errors, and response structure. ChangesQuery filtering for targets and configs list endpoints
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
…CORE-387) Add optional deepObject filter support to the auditor target and config list endpoints, mirroring the example/agents plugin idiom (make_filter_obj_dep + entity_client.list(filter_obj=...)). - schemas.py: add TargetFilter (type, model, description, project, created_at/updated_at) and ConfigFilter (description, project, created_at/updated_at), both subclassing NemoFilter (extra="forbid"). - targets.py / configs.py: parse filter params, forward as filter_obj, echo the filter back in the response, and register the filter schema via generate_openapi_extra_params. page/page_size/sort unchanged; the raw-dict response shape is preserved and only gains a "filter" key. - _filters.py: thin make_filter_dep wrapper that converts the pydantic.ValidationError raised on an unknown filter key into a 422 (the bare make_filter_obj_dep dependency otherwise surfaces a 500). Purely additive: omitting filter params reproduces the prior behavior. Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
3217320 to
55255da
Compare
…E-387) Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
| page: int = Query(default=1, ge=1), | ||
| page_size: int = Query(default=20, ge=1, le=100), | ||
| sort: str = Query(default="-created_at"), | ||
| filter: TargetFilter = Depends(_target_filter_dep), |
There was a problem hiding this comment.
This is going to shadow the filter python built-in. If that's the only way to get the user-facing API we want that may be ok, but it would be best to not shadow built-ins.
What
The auditor plugin's target and config list endpoints previously supported only
page/page_size/sort. This adds query filtering through the standard plugin idiom.TargetFilter(type,model,description,project,created_at,updated_at) andConfigFilter(description,project,created_at,updated_at) inapi/v2/schemas.py— bothNemoFiltersubclasses (extra="forbid"), withDatetimeFilterrange support on the timestamps.list_targets/list_configsnow take afilter[...]dependency (make_filter_obj_dep) and forwardfilter_objtoentity_client.list._filters.make_filter_depwrapper maps the raw pydanticValidationErrorraised on an unknown filter key to HTTP 422 — the platform registers no handler for it, so the bare dependency would surface a 500. Shared infra is untouched.Compatibility
Additive. With no filter the call is identical to before;
page/page_size/sortand the response shape are unchanged (afilterecho key is added). Misspelled filter keys now return 422 (intended).Tests
15 new tests (8 target / 7 config): per-field filtering,
projectnarrowing,created_at$gte/$lteranges, 422 on unknown key, and an empty-filter regression. Plugin suite green (40 passed).Remaining before merge
Run
make refresh-openapito regenerateplugins/nemo-auditor/openapi/openapi.yaml(spec-from-Pydantic; no Stainless — auditor ships hand-written SDK resources).AIRCORE-387
Summary by CodeRabbit