Skip to content

Cover read_vrt GPU/dask+GPU paths and a few VRT parameter combos (#1619)#1620

Merged
brendancol merged 2 commits into
mainfrom
deep-sweep-test-coverage-geotiff-2026-05-11-r3
May 11, 2026
Merged

Cover read_vrt GPU/dask+GPU paths and a few VRT parameter combos (#1619)#1620
brendancol merged 2 commits into
mainfrom
deep-sweep-test-coverage-geotiff-2026-05-11-r3

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

Closes the remaining VRT backend-coverage holes from the geotiff deep-sweep:

  • read_vrt(gpu=True) and read_vrt(gpu=True, chunks=N) pinned: cupy data, cupy _meta on the dask wrap, requested chunk shape preserved.
  • open_geotiff('.vrt', gpu=True[, chunks=N]) dispatch covered.
  • read_vrt(dtype=) widening + float-to-int rejection.
  • read_vrt(name=) override + default-from-stem.
  • open_geotiff(BytesIO, gpu=True) and open_geotiff(BytesIO, chunks=N) error paths.

Test-only change. 11 new tests, all passing on a CUDA host. GPU tests skip cleanly when cupy/CUDA are absent.

Refs #1619. Sweep 3 of the same-day geotiff test-coverage deep-sweep (after #1565, #1586, #1596).

Test plan

  • New file passes locally (pytest xrspatial/geotiff/tests/test_vrt_backend_coverage_2026_05_11.py -v -- 11 passed).
  • Full geotiff suite still passes locally with my changes (pytest xrspatial/geotiff/tests/ -- 1211 passed, 7 deselected for a pre-existing matplotlib palette failure unrelated to this PR).
  • CI passes on a non-GPU runner (the GPU-only class should skip).
  • CI passes on the GPU runner.

Sweep 3 of the geotiff deep-sweep test-coverage pass (2026-05-11). The
prior two same-day passes (#1565, #1586, #1596) closed dask streaming
codec coverage and the specific accuracy bugs that surfaced. This file
closes the remaining backend-coverage holes:

* ``read_vrt(gpu=True)`` returns cupy (no prior test).
* ``read_vrt(gpu=True, chunks=N)`` returns dask Array with cupy ``_meta``
  and the requested chunk shape (no prior test).
* ``open_geotiff('.vrt', gpu=True[, chunks=N])`` routes through
  ``read_vrt`` and surfaces cupy data unchanged.
* ``read_vrt(dtype='float64')`` safe widening; ``dtype='int32'`` rejected
  for a float source (mirrors the ``open_geotiff`` gate).
* ``read_vrt(name='custom')`` override; default-from-stem fallback.
* ``open_geotiff(BytesIO, gpu=True)`` and ``open_geotiff(BytesIO,
  chunks=N)`` raise ``ValueError`` -- the file-like rejection branches
  were unreached by any prior test.

11 new tests, all passing locally on a CUDA host. GPU tests use the same
cupy availability skip predicate as the rest of the geotiff suite, so
non-GPU CI cleanly skips them.

Test-only change. State CSV updated to record sweep 3 outcome.

Refs #1619.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 11, 2026
@brendancol brendancol requested a review from Copilot May 11, 2026 20:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing test coverage for the GeoTIFF VRT read path’s backend matrix (CPU/GPU/Dask+Dask+GPU) and a few read_vrt / open_geotiff parameter behaviors, aligning VRT coverage with the rest of the geotiff reader backends.

Changes:

  • Adds a new test module covering read_vrt(gpu=True), read_vrt(gpu=True, chunks=...), and open_geotiff(...'.vrt'..., gpu/chunks) dispatch behavior.
  • Adds tests for read_vrt(dtype=...) (safe widening + float→int rejection) and read_vrt(name=...) (override + default-from-stem).
  • Updates the deep-sweep state CSV to record the new VRT coverage sweep.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
xrspatial/geotiff/tests/test_vrt_backend_coverage_2026_05_11.py New tests to cover VRT GPU and dask+GPU paths plus dtype/name and file-like rejection cases.
.claude/sweep-test-coverage-state.csv Records sweep-3 state update for geotiff VRT backend/parameter coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


import numpy as np
import pytest
import xarray as xr
Comment on lines +40 to +52
def _cuda_available() -> bool:
if importlib.util.find_spec("cupy") is None:
return False
try:
import cupy
return bool(cupy.cuda.is_available())
except Exception:
return False


_HAS_CUDA = _cuda_available()
_gpu_only = pytest.mark.skipif(not _HAS_CUDA, reason="cupy + CUDA required")

- Remove unused xarray import.
- Rename _cuda_available / _HAS_CUDA to _gpu_available / _HAS_GPU so
  the GPU skip predicate matches the rest of the geotiff test suite
  (test_backend_kwarg_parity_1561, test_attrs_parity_1548, and the
  18 other test files use this name).
@brendancol brendancol merged commit 7331d5c into main May 11, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants