Commit f1f80a6
authored
Add control-plane reporting for tracked runs (flyte run --tracked) (#1356)
## Overview
Tracked runs: the SDK keeps orchestrating everything locally while
reporting run state — actions, attempts, inputs/outputs, HTML reports —
to the control plane, so local runs appear live in the console. Builds
on the IDL in flyteorg/flyte#7737 and the `TrackedRunService` rename
(released as flyteidl2 2.0.40, which this PR pins).
### How it works
- **RemoteRunReporter** — a third `RunRecorder` sink alongside the TUI
tracker and SQLite store. The recorder observer contract is synchronous
and fires from async controller code *and* the threads that run sync
tasks, so the sink is a sync enqueue facade over async I/O: `record_*`
calls capture a fully-computed event under a lock (per-attempt monotonic
versions; attempts start at 1 per the server contract) and a dedicated
background event loop batches `TrackedRunService.ReportActions` calls
and performs the signed-URL uploads (the same background-loop shape as
`flyte.syncify`). Terminal events trigger a bounded flush barrier at run
end. Reporting is best-effort and never fails or hangs the run (unless
strict mode is on).
- **Data path routes like everything else**: artifacts upload via
`DataProxyService.CreateUploadLocation` signed PUT URLs with the
`tracked-runs/<run>/<action>[/<attempt>]` filename_root scheme, routed
by `ClusterService.SelectCluster(OPERATION_TRACKED_RUN_DATA)` — an org
with a directly-reachable data plane cluster uploads straight to that
cluster's store; an org without one is served by the control plane's own
store. The reporter stamps the routing cluster onto reported attempt
events so reads later route to the same store. Inputs upload before
CreateRun (deterministic path, no URI on the event); outputs/report URIs
attach to the terminal event after their uploads complete. Reports also
flush live mid-run so the report tab updates while the run executes.
- **Opt-in surface** (one naming family, anchored on the flag):
- `flyte run --local --tracked [--tracked-strict]`
- config: `local.tracked` / `local.tracked_strict` (section mirrors
`local.persistence`)
- `flyte.init(local_tracked=..., local_tracked_strict=...)`; `flyte
create config --local-tracked`
- runcontext: `flyte.with_runcontext(mode="local", tracked=True)`
- Requires project/domain; degrades gracefully with one warning when no
client is initialized. `--tracked-strict` fails the run loudly on the
first reporting failure (for debugging reporting itself). SIGINT/SIGTERM
abort-flushes in-flight actions as ABORTED. `Run.url` points at the
console tracked-runs page. Falsy outputs (`0`, `""`, `[]`, `False`)
report correctly (presence, not truthiness). File/Dir raw data never
uploads — only the three metadata artifacts (inputs.pb / outputs.pb /
report.html) reach the dataproxy.
The deck feature (`@env.task(report=True)`, `flyte.report`) and the
`@trace` decorator are unrelated and untouched.
## Test Plan
- 688 unit tests green on the released flyteidl2 pin (reporter lifecycle
incl. retries/ordering/flush barrier/failure isolation/strict mode,
upload helper, client protocol, CLI flags, config plumbing).
- Live E2E against three environments running a backend that implements
`TrackedRunService`:
- a single-process development stack: full lifecycle, watches, replay
idempotency.
- a hosted control plane with a directly-reachable data plane cluster:
runs + inputs/outputs + reports render in the console; artifacts land in
the cluster's metadata store, with the routing cluster recorded on
attempts.
- a hosted control plane where artifacts are served by the control
plane's own store — the fallback leg of the routed data path, verified
end to end on the released flyteidl2 pin.
## Rollout Plan
The feature is opt-in per run/config and requires a control plane that
implements `TrackedRunService`; nothing changes for users who don't pass
`--tracked`.
## Rollback Plan
Revert; the feature is client-side and opt-in.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>1 parent 768f76e commit f1f80a6
20 files changed
Lines changed: 3399 additions & 79 deletions
File tree
- src/flyte
- _internal/controllers
- _persistence
- cli
- config
- remote
- _client
- report
- tests
- cli
- flyte/remote
- persistence
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| 238 | + | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
| |||
280 | 284 | | |
281 | 285 | | |
282 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
283 | 292 | | |
284 | 293 | | |
285 | 294 | | |
| |||
341 | 350 | | |
342 | 351 | | |
343 | 352 | | |
| 353 | + | |
| 354 | + | |
344 | 355 | | |
345 | 356 | | |
346 | 357 | | |
| |||
435 | 446 | | |
436 | 447 | | |
437 | 448 | | |
| 449 | + | |
| 450 | + | |
438 | 451 | | |
439 | 452 | | |
440 | 453 | | |
| |||
781 | 794 | | |
782 | 795 | | |
783 | 796 | | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
784 | 813 | | |
785 | 814 | | |
786 | 815 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
| |||
374 | 376 | | |
375 | 377 | | |
376 | 378 | | |
| 379 | + | |
| 380 | + | |
377 | 381 | | |
378 | 382 | | |
379 | 383 | | |
| |||
406 | 410 | | |
407 | 411 | | |
408 | 412 | | |
409 | | - | |
| 413 | + | |
| 414 | + | |
410 | 415 | | |
411 | 416 | | |
412 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
30 | | - | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | | - | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
| 40 | + | |
| 41 | + | |
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
| |||
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
77 | 86 | | |
78 | 87 | | |
79 | 88 | | |
| |||
121 | 130 | | |
122 | 131 | | |
123 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
124 | 153 | | |
125 | 154 | | |
126 | 155 | | |
| |||
140 | 169 | | |
141 | 170 | | |
142 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
143 | 176 | | |
144 | 177 | | |
145 | 178 | | |
| |||
173 | 206 | | |
174 | 207 | | |
175 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
176 | 212 | | |
177 | 213 | | |
178 | 214 | | |
| |||
186 | 222 | | |
187 | 223 | | |
188 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
189 | 228 | | |
190 | 229 | | |
191 | 230 | | |
| |||
208 | 247 | | |
209 | 248 | | |
210 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
211 | 253 | | |
212 | 254 | | |
213 | 255 | | |
| |||
226 | 268 | | |
227 | 269 | | |
228 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
229 | 274 | | |
230 | | - | |
| 275 | + | |
231 | 276 | | |
232 | 277 | | |
233 | 278 | | |
| |||
241 | 286 | | |
242 | 287 | | |
243 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
244 | 292 | | |
245 | 293 | | |
246 | 294 | | |
| |||
250 | 298 | | |
251 | 299 | | |
252 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
253 | 304 | | |
254 | 305 | | |
255 | 306 | | |
| |||
260 | 311 | | |
261 | 312 | | |
262 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
263 | 317 | | |
264 | 318 | | |
265 | 319 | | |
| |||
0 commit comments