feat: Implemented search annotations for runs #68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TODO
EXISTSneeded for searching for Keys? IsEQUALSsufficient?Description
Closes #45
Implemented a new API to search annotations for runs.
Background
Annotations are
key-valuepairs. The following examples of annotations (e.g.key = value):env=productionteam=backendThis PR allows searches for key/value strings.
Features
/api/pipeline_runs/search/) to search key/value in annotations.(S1 and S2) or (S3 or S4)Use Cases and Examples
1. Key equals a string
Find runs where annotation key equals "environment":
{ "annotation_filters": { "filters": [ {"operator": "equals", "key": "environment"} ] } }2. Key contains substring AND value in set
Find runs where key contains "env" AND value is "prod" or "staging":
{ "annotation_filters": { "filters": [ {"operator": "contains", "key": "env"}, {"operator": "in_set", "values": ["prod", "staging"]} ], "operator": "and" } }3. Complex: (key contains OR value contains) AND key NOT contains
Find runs where (key contains "env" OR any value contains "prod") AND key NOT contains "deprecated":
{ "annotation_filters": { "filters": [ { "filters": [ {"operator": "contains", "key": "env"}, {"operator": "contains", "value": "prod"} ], "operator": "or" }, {"operator": "contains", "value": "deprecated", "negate": true} ], "operator": "and" } }Test Plan
uv run pytest tests/test_pipeline_run_search.py -v/api/pipeline_runs/<ID>/annotations/<KEY>/)/api/pipeline_runs/<ID>/annotations/)/api/pipeline_runs/search/)Demo
part1.mov
part2.mov