Skip to content

Optimize and migrate MRMS and NClimGridDaily data sources on obstore - #1061

Merged
negin513 merged 8 commits into
NVIDIA:mainfrom
negin513:obstore-migrate-mrms-nclimgrid
Aug 13, 2026
Merged

Optimize and migrate MRMS and NClimGridDaily data sources on obstore#1061
negin513 merged 8 commits into
NVIDIA:mainfrom
negin513:obstore-migrate-mrms-nclimgrid

Conversation

@negin513

@negin513 negin513 commented Aug 12, 2026

Copy link
Copy Markdown
Member

Earth2Studio Pull Request

Description

Closes NVIDIA/physicsnemo-roadmap#2882, closes NVIDIA/physicsnemo-roadmap#2885.

Migrates the MRMS and NClimGridDaily data sources from s3fs to obstore, continuing the migration series (GOES #1024, Himawari AHI #1043, ISD/IBTrACS/CFS-reforecast/OPERA #1058):

  • MRMS — S3 object reads move to obstore via the shared byte-range helpers. Day-directory listings go through obstore_list_prefix with per-instance memoization: past (complete) days are cached so repeated fetches over the same day share one LIST request, while the current UTC day is always re-listed (the GOES pattern). Gzip decompression and cache writes now run in a worker thread. Cache file names hash the same bucket-prefixed s3:// URIs as before, so warm caches remain valid.
  • MRMS decode fix — fetch time was dominated by latlons(), which decodes full 2-D coordinate arrays (~8 s per 3500×7000 file) even though the source only keeps the 1-D axes of the regular CONUS grid. The axes are now computed from grid-definition header keys (~0.1 ms, identical to within 2×10⁻⁶ degrees on the 0.01° grid), with latlons() kept as a fallback for non-regular grids. The decode also moves into a worker thread so concurrent (time, product) tasks no longer serialize on the event loop.
  • NClimGridDaily — the synchronous s3fs streaming reads (per-slice HDF5 seeks over the network) are replaced by downloading each monthly NetCDF (~58 MB) once into the cache via obstore_fetch_to_cache, shared by every (day, variable) slice of that month. Months whose per-slice caches are already warm skip the download entirely.

Performance

Full lexicon, cache=False, 3 reps, same host and time window:

Data source File type Before (main) After (PR) Speedup
MRMS (2 vars, 2 same-day times) GRIB2 gz (one per product/time, S3) 31.4–36.8 s 4.6–5.4 s ~6.4×
NClimGridDaily (4 vars, 3 days) NetCDF (monthly, ~58 MB, S3) 6.4–16.4 s 4.6–5.8 s ~1.2× median, no seek-storm outliers

Nearly all of the MRMS win comes from the header-key axis computation and threaded decode; the obstore transport itself was a wash there (gunzip is 0.01 s, download 0.6 s — latlons() was ~8 s of every ~9 s task). Output verified: identical shapes, no NaN change, axes match latlons() to float rounding.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes (test_mrms.py, test_nclimgrid.py; mocked NClimGrid test updated to the new download seam).
  • The documentation is up to date with these changes.
  • The CHANGELOG.md is up to date with these changes.
  • An issue is linked to this pull request (physicsnemo-roadmap task issues above).
  • Assess and address Greptile feedback (AI code review bot for guidance; use discretion, addressing all feedback is not required).

Dependencies

No new dependencies; obstore and obspec are already core dependencies.

Replaces the s3fs filesystem with an obstore S3 store using the shared
byte-range helpers. Day-directory listings go through obstore_list_prefix
with per-instance memoization: past (complete) days are cached so repeated
fetches over the same day share one LIST request, while the current UTC
day is always re-listed. Gzip decompression and the cache write now run
in a worker thread instead of blocking the event loop. Cache file names
hash the same bucket-prefixed s3:// URI as before, so warm caches remain
valid.
Replaces the synchronous s3fs streaming reads with obstore. Each monthly
NetCDF (~58 MB) is now downloaded once into the cache via
obstore_fetch_to_cache and shared by every (day, variable) slice of that
month, instead of every slice independently seeking through the remote
file over fsspec. Months whose per-slice caches are already warm skip
the download entirely. Benchmarked at ~1.2x faster medians for
multi-day requests with far fewer network-latency outliers (16 s worst
case dropped to 6 s).
MRMS fetch time was dominated by latlons(), which decodes full 2-D
coordinate arrays (~8 s per 3500x7000 file) even though the data source
only keeps the 1-D axes of the regular CONUS lat/lon grid. Compute the
axes from the grid-definition header keys instead (~0.1 ms, verified
identical to within 2e-6 degrees on a 0.01-degree grid), keeping
latlons() as a fallback for non-regular grids. The decode also moves
into a worker thread so concurrent (time, product) tasks no longer
serialize on the event loop.

Full-lexicon fetch of 2 times x 2 products: ~32 s -> ~5 s.
@copy-pr-bot

copy-pr-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR migrates MRMS and NClimGridDaily remote reads from s3fs to obstore and accelerates MRMS coordinate decoding.

  • Adds memoized MRMS prefix listings, threaded decompression, and header-derived regular-grid axes.
  • Downloads each NClimGrid monthly NetCDF once for reuse by its requested day and variable slices.
  • Updates NClimGrid tests and the changelog for the new transport paths.

Confidence Score: 4/5

The concurrent NClimGridDaily fetch failure should be fixed before merging.

Overlapping fetches for different uncached months can replace the shared monthly-path dictionary before an earlier request consumes it, causing that request to fail with KeyError.

Files Needing Attention: earth2studio/data/nclimgrid.py

Important Files Changed

Filename Overview
earth2studio/data/mrms.py Migrates discovery and reads to obstore and moves optimized GRIB decoding off the event loop; no actionable defect was established for supported products.
earth2studio/data/nclimgrid.py Adds monthly local downloads, but stores invocation-specific paths on the instance, allowing concurrent fetches to overwrite one another.
test/data/test_nclimgrid.py Updates the mocked download seam but does not cover overlapping async fetches on one instance.
CHANGELOG.md Documents the MRMS and NClimGridDaily obstore migrations and MRMS decoding optimization.

Reviews (1): Last reviewed commit: "Compute MRMS lat/lon axes from grib head..." | Re-trigger Greptile

Comment thread earth2studio/data/nclimgrid.py
@negin513 negin513 changed the title Migrate MRMS and NClimGridDaily data sources to obstore Migrate and optimize MRMS and NClimGridDaily data sources on obstore Aug 13, 2026
@negin513 negin513 self-assigned this Aug 13, 2026
@negin513 negin513 changed the title Migrate and optimize MRMS and NClimGridDaily data sources on obstore Optimize and migrate MRMS and NClimGridDaily data sources on obstore Aug 13, 2026
Comment thread CHANGELOG.md Outdated
Comment thread earth2studio/data/mrms.py Outdated

@NickGeneva NickGeneva 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.

No major concerns, approved to unblock

@negin513

Copy link
Copy Markdown
Member Author

/ok to test

@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

/ok to test

@negin513, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

@negin513

Copy link
Copy Markdown
Member Author

/okay to test 18552ec

@negin513
negin513 merged commit 33eca38 into NVIDIA:main Aug 13, 2026
15 checks passed
@negin513
negin513 deleted the obstore-migrate-mrms-nclimgrid branch August 13, 2026 06:10
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.

2 participants