Skip to content

Avoid lazy NetCDF writes during evaluation#133

Merged
zhongwangwei merged 1 commit into
mainfrom
agent/eager-evaluation-netcdf-write
Jul 8, 2026
Merged

Avoid lazy NetCDF writes during evaluation#133
zhongwangwei merged 1 commit into
mainfrom
agent/eager-evaluation-netcdf-write

Conversation

@zhongwangwei

Copy link
Copy Markdown
Owner

What changed

  • Materialize grid evaluation metric and score results before NetCDF output.
  • Added a regression test that verifies lazy Dask-backed evaluation outputs are loaded before write.

Why

Windows/netCDF4 can hang when to_netcdf() writes an output file while still lazily reading source NetCDF arrays. This mirrors the station scanner pattern that separates source reads from target HDF5 writes.

Validation

  • python -m pytest tests/test_netcdf_lifecycle_atomic.py tests/test_performance_optimizations.py -q
  • python -m ruff check src/openbench/core/evaluation.py tests/test_netcdf_lifecycle_atomic.py
  • python -m ruff format --check src/openbench/core/evaluation.py tests/test_netcdf_lifecycle_atomic.py

Evaluation metric and score results are materialized before NetCDF output so source-file reads do not overlap with HDF5 writes on Windows runners.

Constraint: netCDF4/HDF5 can hang when lazy source reads overlap target writes on Windows CI.
Rejected: Eager loading inside write_netcdf_atomic | would force large mfdataset combine paths into memory.
Confidence: high
Scope-risk: narrow
Directive: Keep large-file combine paths lazy unless a caller explicitly materializes bounded outputs.
Tested: python -m pytest tests/test_netcdf_lifecycle_atomic.py tests/test_performance_optimizations.py -q; python -m ruff check src/openbench/core/evaluation.py tests/test_netcdf_lifecycle_atomic.py; python -m ruff format --check src/openbench/core/evaluation.py tests/test_netcdf_lifecycle_atomic.py
Not-tested: Full GitHub Actions matrix after this commit.
@zhongwangwei zhongwangwei marked this pull request as ready for review July 8, 2026 19:37
@zhongwangwei zhongwangwei merged commit 18933cf into main Jul 8, 2026
11 checks passed
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.

1 participant