Commit 24e002e
Add gzip support for load_ndjson() (#207)
Summary:
This PR adds support for loading gzip-compressed NDJSON files in the `load_ndjson()` function, fixing an issue where the CLI claimed to support `.ndjson.gz` files but the function only used `open()`.
## Supported Formats
| Format | Extension | Description |
|--------|-----------|-------------|
| Uncompressed | `.ndjson` | Standard NDJSON (existing) |
| Gzip compressed | `.ndjson.gz` | Whole file compressed |
| Gzip member concatenation | `.bin.ndjson` | Each line compressed separately |
## Changes
- **`tools/prettify_ndjson.py`**:
- Added `import gzip`
- Added `_is_gzip_file()` helper function to detect compressed files
- Modified `load_ndjson()` to use `gzip.open()` for compressed files
- Updated docstring to document supported formats
- **`tests/test_tritonparse.py`**:
- Added `test_load_ndjson_gzip_support()` test using existing `.ndjson.gz` test file
## Testing
Uses existing test file: `tests/example_output/parsed_output_complex/dedicated_log_triton_trace_findhao__mapped.ndjson.gz`
Pull Request resolved: #207
Reviewed By: wychi
Differential Revision: D88171069
Pulled By: FindHao
fbshipit-source-id: 701a238a3d9d34d1d096834088a4ac87cb16ed091 parent 311e016 commit 24e002e
File tree
2 files changed
+45
-1
lines changed- tests
- tritonparse/tools
2 files changed
+45
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
310 | 339 | | |
311 | 340 | | |
312 | 341 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| |||
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
109 | 119 | | |
110 | 120 | | |
111 | 121 | | |
| |||
122 | 132 | | |
123 | 133 | | |
124 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
125 | 140 | | |
126 | | - | |
| 141 | + | |
127 | 142 | | |
128 | 143 | | |
129 | 144 | | |
| |||
0 commit comments