Commit 38dc5e7
authored
feat: Search created by user in pipeline run API (#108)
### TL;DR
Implemented search `created_by` user in Pipeline Runs.
### What changed?
#### Functionality
- API `GET /api/pipeline_runs/`
- Search `created_by` user in `filter_query`. Example query (not URL encoded for example):
```json
/api?filter_query={"and": [{"value_equals": {"key": "system/pipeline_run.created_by", "value": "alice@example.com"}}]}
```
- Annotation value `me` is supported for `created_by` search.
- API `POST /api/pipeline_runs/`
- Copies the `created_by` data to the annotations table for future searching. Example pipeline run annotations table after API is called:
| pipeline_run_id | key | value |
|---|---|---|
| `abc123` | `system/pipeline_run.created_by` | `alice@example.com` |
- API `[PUT|DELETE] /api/pipeline_runs/{id}/annotations/{key}`
- Prevent (create, update, delete) of annotations with `system/` prefix. Reserved for system annotation usage.
#### Other
- **Database migration**: Added backfill logic to populate existing pipeline runs with `created_by` annotations. Example what a pipeline run's created by user would look like in the annotations table:
| pipeline_run_id | key | value |
|-----------------|-----|-------|
| 42 | system/pipeline_run.created_by | alice@example.com |
### How to test?
```
uv run pytest tests/test_api_server_sql.py tests/test_filter_query_sql.py tests/test_database_ops.py
```
1. Create pipeline runs with different `created_by` values
2. Use filter queries like `{"and": [{"value_equals": {"key": "system/pipeline_run.created_by", "value": "alice"}}]}` to search by creator
3. Test the `"me"` placeholder: `{"and": [{"value_equals": {"key": "system/pipeline_run.created_by", "value": "me"}}]}`
4. Verify that attempts to set/delete system annotations return 422 errors
5. Test that unsupported predicates on system keys (like `value_contains`) are rejected
### Why make this change?
- This enables users to search for pipeline runs by creator using the new filter query system.
- Following safety guards and synchronization will allow old and new data (`create_by`) to be searchable with the new filter.
- Preventing (create, delete, update) system prefix in annotations
- Saving `created_by` to annotations table when starting a Pipeline Run1 parent 538bdc0 commit 38dc5e7
7 files changed
Lines changed: 968 additions & 13 deletions
File tree
- cloud_pipelines_backend
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
| |||
105 | 113 | | |
106 | 114 | | |
107 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
108 | 129 | | |
109 | 130 | | |
110 | 131 | | |
| |||
295 | 316 | | |
296 | 317 | | |
297 | 318 | | |
| 319 | + | |
298 | 320 | | |
299 | 321 | | |
300 | 322 | | |
| |||
317 | 339 | | |
318 | 340 | | |
319 | 341 | | |
| 342 | + | |
320 | 343 | | |
321 | 344 | | |
322 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
62 | 71 | | |
63 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
64 | 77 | | |
65 | | - | |
| 78 | + | |
66 | 79 | | |
67 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
68 | 84 | | |
69 | | - | |
| 85 | + | |
| 86 | + | |
70 | 87 | | |
71 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
72 | 93 | | |
73 | | - | |
| 94 | + | |
74 | 95 | | |
75 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
76 | 101 | | |
77 | 102 | | |
78 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
11 | 27 | | |
12 | 28 | | |
13 | 29 | | |
| |||
44 | 60 | | |
45 | 61 | | |
46 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
47 | 135 | | |
48 | 136 | | |
49 | 137 | | |
| |||
79 | 167 | | |
80 | 168 | | |
81 | 169 | | |
82 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
83 | 176 | | |
84 | 177 | | |
85 | 178 | | |
| |||
95 | 188 | | |
96 | 189 | | |
97 | 190 | | |
| 191 | + | |
98 | 192 | | |
99 | 193 | | |
100 | 194 | | |
101 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
102 | 198 | | |
103 | 199 | | |
104 | 200 | | |
| |||
163 | 259 | | |
164 | 260 | | |
165 | 261 | | |
166 | | - | |
| 262 | + | |
| 263 | + | |
167 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
168 | 270 | | |
169 | 271 | | |
170 | 272 | | |
171 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
172 | 277 | | |
173 | 278 | | |
174 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
175 | 285 | | |
176 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
177 | 291 | | |
178 | 292 | | |
179 | 293 | | |
| |||
0 commit comments