Commit fa20a74
feat: Add bigframes.execution_history API to track BigQuery jobs (#16588)
This PR promotes execution_history() to the top-level bigframes
namespace and upgrades it to track rich metadata for every BigQuery job
executed during your session.
Key User Benefits:
- Easier Access: Call bigframes.execution_history() directly instead of
digging into sub-namespaces.
- Rich Metadata Tracking: Captures structured statistics for both Query
Jobs and Load Jobs including:
- job_id and a direct Google Cloud Console URL for easy debugging.
- Performance metrics: total_bytes_processed, duration_seconds, and
slot_millis.
- Query details (truncated preview of the SQL ran).
- Clean, Focused Logs: Automatically filters out internal library
overhead (like schema validations and index uniqueness checks) so your
history only shows the data processing steps you actually care about.
Usage Example:
```
1 import bigframes.pandas as bpd
2 import pandas as pd
3 import bigframes
4
5 # ... run some bigframes operations ...
6 df = bpd.read_gbq("SELECT 1")
7
8 # Upload some local data (triggers a Load Job)
9 bpd.read_pandas(pd.DataFrame({'a': [1, 2, 3]}))
10
11 # Get a DataFrame of all BQ jobs run in this session
12 history = bigframes.execution_history()
13
14 # Inspect recent queries, their costs, and durations
15 print(history[['job_id', 'job_type', 'total_bytes_processed', 'duration_seconds', 'query']])
```
verified at:
1. vs code notebook: screen/8u2yhaRV9iHbDbF
2. colab notebook: screen/9L8VrP5y9DXhnZz
More testcases and notebook update will be checked in using separate PRs
for easier review.
Fixes #<481840739> 🦕
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent dec9813 commit fa20a74Copy full SHA for fa20a74
13 files changed
+420-68Lines changed: 420 additions & 68 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- packages/bigframes
- bigframes
- core
- sql
- session
- tests
- system/small
- session
- unit
- session
Expand file treeCollapse file tree
Open diff view settings
Collapse file
packages/bigframes/bigframes/__init__.py
Copy file name to clipboardExpand all lines: packages/bigframes/bigframes/__init__.py+2Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
45 | 45 | |
46 | 46 | |
47 | 47 | |
| 48 | + |
48 | 49 | |
49 | 50 | |
50 | 51 | |
| ||
69 | 70 | |
70 | 71 | |
71 | 72 | |
| 73 | + |
72 | 74 | |
73 | 75 | |
74 | 76 | |
|
Collapse file
packages/bigframes/bigframes/core/global_session.py
Copy file name to clipboardExpand all lines: packages/bigframes/bigframes/core/global_session.py+8Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
124 | 124 | |
125 | 125 | |
126 | 126 | |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
127 | 135 | |
128 | 136 | |
129 | 137 | |
|
Collapse file
packages/bigframes/bigframes/core/sql/__init__.py
Copy file name to clipboardExpand all lines: packages/bigframes/bigframes/core/sql/__init__.py+2-1Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | | - |
15 | 14 | |
16 | 15 | |
17 | 16 | |
18 | 17 | |
19 | 18 | |
| 19 | + |
| 20 | + |
20 | 21 | |
21 | 22 | |
22 | 23 | |
|
Collapse file
packages/bigframes/bigframes/session/__init__.py
Copy file name to clipboardExpand all lines: packages/bigframes/bigframes/session/__init__.py+48Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
109 | 109 | |
110 | 110 | |
111 | 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 | + |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
112 | 152 | |
113 | 153 | |
114 | 154 | |
| ||
233 | 273 | |
234 | 274 | |
235 | 275 | |
| 276 | + |
236 | 277 | |
237 | 278 | |
238 | 279 | |
| ||
371 | 412 | |
372 | 413 | |
373 | 414 | |
| 415 | + |
| 416 | + |
| 417 | + |
| 418 | + |
| 419 | + |
| 420 | + |
| 421 | + |
374 | 422 | |
375 | 423 | |
376 | 424 | |
|
Collapse file
packages/bigframes/bigframes/session/loader.py
Copy file name to clipboardExpand all lines: packages/bigframes/bigframes/session/loader.py+5Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
52 | 52 | |
53 | 53 | |
54 | 54 | |
| 55 | + |
| 56 | + |
55 | 57 | |
56 | 58 | |
57 | 59 | |
| ||
623 | 625 | |
624 | 626 | |
625 | 627 | |
| 628 | + |
| 629 | + |
| 630 | + |
626 | 631 | |
627 | 632 | |
628 | 633 | |
|
Collapse file
packages/bigframes/bigframes/session/metrics.py
Copy file name to clipboardExpand all lines: packages/bigframes/bigframes/session/metrics.py+186-23Lines changed: 186 additions & 23 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
15 | 15 | |
16 | 16 | |
17 | 17 | |
| 18 | + |
18 | 19 | |
19 | | - |
| 20 | + |
20 | 21 | |
21 | 22 | |
22 | | - |
23 | 23 | |
| 24 | + |
| 25 | + |
24 | 26 | |
25 | 27 | |
26 | 28 | |
27 | 29 | |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 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 | + |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
28 | 143 | |
29 | 144 | |
30 | 145 | |
31 | 146 | |
32 | 147 | |
33 | 148 | |
34 | 149 | |
| 150 | + |
35 | 151 | |
36 | 152 | |
37 | 153 | |
38 | | - |
| 154 | + |
39 | 155 | |
40 | 156 | |
41 | 157 | |
| ||
57 | 173 | |
58 | 174 | |
59 | 175 | |
60 | | - |
61 | | - |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | + |
62 | 182 | |
63 | 183 | |
64 | 184 | |
65 | 185 | |
66 | 186 | |
67 | 187 | |
68 | | - |
69 | | - |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
70 | 201 | |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | + |
75 | 232 | |
76 | 233 | |
77 | 234 | |
78 | 235 | |
79 | 236 | |
80 | 237 | |
81 | 238 | |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | + |
| 244 | + |
88 | 245 | |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
| 246 | + |
| 247 | + |
| 248 | + |
| 249 | + |
| 250 | + |
| 251 | + |
| 252 | + |
| 253 | + |
| 254 | + |
| 255 | + |
| 256 | + |
| 257 | + |
95 | 258 | |
96 | 259 | |
97 | 260 | |
|
0 commit comments