Skip to content

Weather splitter fix - #560

Open
shubhamkumar-bot wants to merge 7 commits into
google:mainfrom
shubhamkumar-bot:weather-splitter-fix
Open

Weather splitter fix#560
shubhamkumar-bot wants to merge 7 commits into
google:mainfrom
shubhamkumar-bot:weather-splitter-fix

Conversation

@shubhamkumar-bot

Copy link
Copy Markdown

No description provided.

mmarusiak and others added 3 commits June 12, 2026 09:55
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.
- 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).
assert splitter.should_skip()

def test_splits_only_missing_files(self, data_dir, grib_splitter):
input_path = f'{data_dir}/era5_sample.grib'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create all the paths using the os.path module please.

num_files = 0
for f in os.listdir(tmpdir):
dest_file_path = f'{prefix}{f.replace(delimiter, "/")}'
dest_file_path = os.path.join(prefix, *f.split(delimiter))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: os.path.join(prefix, f.replace(delimiter, "/")) seems more readable

@j9sh264 j9sh264 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants