Skip to content

Extract shared HRRR virtual base (move-only refactor, no new datasets)#743

Draft
mrshll wants to merge 2 commits into
mainfrom
claude/hrrr-virtual-shared-base-a8s89q
Draft

Extract shared HRRR virtual base (move-only refactor, no new datasets)#743
mrshll wants to merge 2 commits into
mainfrom
claude/hrrr-virtual-shared-base-a8s89q

Conversation

@mrshll

@mrshll mrshll commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

Move-only refactor extracting a shared HRRR virtual base from the shipped noaa-hrrr-forecast-48-hour-virtual, structured for byte-fidelity review. No new datasets — those stack on top in #740.

Copy-then-edit structure

Two commits, deliberately:

  1. Copy 48-hour virtual template config and region job to shared module paths — byte-for-byte cp of the two files to noaa/hrrr/forecast_virtual_template_config.py and forecast_virtual_region_job.py, zero edits.
  2. Extract shared HRRR virtual base; hoist windowed update jobs to VirtualRegionJob — the actual refactor. Because commit 1 is verbatim, this commit's diff on the 2,100-line catalog file is just +100/−76 — the ~1,900 lines of variable definitions, factories, and filters are provably untouched.

What the edit commit does

  • NoaaHrrrForecastVirtualTemplateConfig base with per-variant hooks (forecast_length, _dataset_attributes, expected-forecast-length values/statistics, _catalog_data_vars, dims-driven vertical coordinates); the 48-hour dataset becomes thin subclasses with unchanged public class names, module path, and template location.
  • One shared NoaaHrrrForecastVirtualSourceFileCoord/NoaaHrrrForecastVirtualRegionJob; the single-polling-job operational_update_jobs — previously duplicated line-for-line by this dataset and GEFS 10-day spatial — moves to common VirtualRegionJob parameterized by an operational_update_window classvar. GEFS migrates onto it (sets its 24h window); example_virtual's stub becomes a classvar teaching note; a construction-time guard rejects a virtual dataset using the default update factory without a declared window.
  • Caches the HRRR lat/lon grid computation (~250ms/call, one grid shared by every HRRR dataset, requested once per zarr group per template build).
  • docs/virtual_datasets.md implementer contract updated; ruff RUF012 per-file-ignore glob widened for the shared module name.

Verification

  • Byte-identity gate: uv run main noaa-hrrr-forecast-48-hour-virtual update-template regenerates the checked-in template with zero diff on this branch.
  • Full fast suite passes on this branch standalone (1589 tests), including GEFS 10-day spatial on the migrated method and the registry-driven template/CF-compliance suites.
  • Earlier in the stack's development, the 48-hour slow tests (backfill+update snapshot, drop-in-vs-materialized) passed on this shared code.

Stack

#740 (18-hour + 48-hour-fast datasets) is based on this branch.

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits July 13, 2026 13:52
…paths

Byte-for-byte copies of forecast_48_hour_virtual/{template_config,region_job}.py
at their new shared locations, with no edits, so the following commit's diff
shows exactly what the extraction changes relative to the shipped code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PSMv3HgaxKHdUaLk56bXxt
…alRegionJob

Edit the verbatim copies from the previous commit into the shared form:
forecast_virtual_template_config.py keeps the full variable catalog,
coordinate builders, and encoding factories unchanged and turns the class
head into NoaaHrrrForecastVirtualTemplateConfig with per-variant hooks
(forecast_length, dataset-identity attributes via _dataset_attributes,
expected-forecast-length values/statistics, _catalog_data_vars, and
dims-driven vertical coordinates); forecast_virtual_region_job.py renames
the coord and job classes to the shared NoaaHrrrForecastVirtual* names and
adds the hrrr_virtual_chunk_containers factory. The 48-hour dataset becomes
thin subclasses with unchanged public class names and module paths, and its
checked-in template regenerates byte-identically.

The single-polling-job operational_update_jobs, previously duplicated
line-for-line by this dataset and GEFS 10-day spatial, moves to common
VirtualRegionJob parameterized by an operational_update_window classvar;
GEFS sets its 24h window and example_virtual's stub becomes a classvar
teaching note. A construction-time guard rejects a virtual dataset whose
region job uses the default update factory without declaring the window.
Cache the HRRR latitude/longitude grid computation, which every HRRR
dataset shares and each template build requests once per zarr group.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PSMv3HgaxKHdUaLk56bXxt
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