Issue 538: Skip individual split files that already exist - #548
Issue 538: Skip individual split files that already exist#548mmarusiak wants to merge 2 commits into
Conversation
Previously, all three splitters used an all-or-nothing approach: if any output file existed (via wildcard match), the entire input file was skipped. If even one output file was missing, the splitter re-split the whole input and overwrote all previously created children. Now each splitter checks existence per output file and only generates the missing ones: - GribSplitter: replaced the upfront should_skip() guard with a per-key should_skip_file() check inside the message loop, using a skipped_keys set to avoid redundant filesystem calls for the same output path. - GribSplitterV2: already checked per-file before running grib_copy, but the upload loop was copying every file grib_copy produced (including already-existing ones). Fixed by filtering the upload loop to only paths in output_paths. - NetCdfSplitter: removed the upfront should_skip() guard and moved the existence check into _write_dataset(), which now returns a bool so split_data() can track how many files were actually written. Added test_splits_only_missing_files for both GribSplitter/GribSplitterV2 (parametrized) and NetCdfSplitter: full split, delete one output file, re-split, assert only the deleted file was recreated and all others have unchanged modification times.
| if key not in outputs: | ||
| if self.should_skip_file(key): | ||
| skipped_keys.add(key) | ||
| del grb |
There was a problem hiding this comment.
We should log these skipped files to improve pipeline telemetry and simplify troubleshooting downstream.
| for flat_target in os.listdir(tmpdir): | ||
| dest_file_path = f'{prefix}{flat_target.replace(delimiter, slash)}' | ||
| if dest_file_path not in output_paths_set: | ||
| continue |
There was a problem hiding this comment.
Same here, let's log these skipped files.
| # Storing data in HDF5 is advantageous since it allows opening NetCDF files with buffered readers. | ||
| output_path = self._get_output_for_dataset(dataset, split_dims) | ||
| if self.should_skip_file(output_path): | ||
| return False |
There was a problem hiding this comment.
Same here, let's log these skipped files :)
Alternatively, we can also add a log in the should_skip_file method.
|
Thank you for implementing these changes @mmarusiak! Could you please pull the latest from main and bump the version numbers in both |
|
Hey @mmarusiak, checking in on this PR! No rush, but wanted to see if you had a chance to review the feedback. If you're blocked on anything or need a hand addressing the comments, just let us know. Happy to help! |
- Resolve file_splitters.py conflict: keep issue google#538 skip of already-split files while adopting upstream's recursive copy_dir upload. - Log each skipped (already-split) file across GribSplitter, GribSplitterV2, and NetCdfSplitter for pipeline telemetry. - Patch-bump VERSION.txt (0.2.2 -> 0.2.3) and weather_sp/setup.py (0.3.10 -> 0.3.11).
|
@j9sh264 sorry for the delay, but finally managed to find some time to rebase and bump version! |
Fixes #538
Previously, all three splitters used an all-or-nothing approach: if any output file existed (via wildcard match), the entire input file was skipped. If even one output file was missing, the splitter re-split the whole input and overwrote all previously created children.
Now each splitter checks existence per output file and only generates the missing ones:
Added test_splits_only_missing_files for both GribSplitter/GribSplitterV2 (parametrized) and NetCdfSplitter: full split, delete one output file, re-split, assert only the deleted file was recreated and all others have unchanged modification times.