Skip to content

Reject overview_level / on_gpu_failure on VRT sources (#1685)#1689

Merged
brendancol merged 2 commits into
xarray-contrib:mainfrom
brendancol:deep-sweep-api-consistency-geotiff-2026-05-12-v2-03
May 12, 2026
Merged

Reject overview_level / on_gpu_failure on VRT sources (#1685)#1689
brendancol merged 2 commits into
xarray-contrib:mainfrom
brendancol:deep-sweep-api-consistency-geotiff-2026-05-12-v2-03

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • open_geotiff documents overview_level and on_gpu_failure as supported, but the VRT dispatch branch routes through read_vrt whose signature accepts neither. Calling open_geotiff('mosaic.vrt', overview_level=2) returned full-resolution data with no warning -- the same silent kwarg-drop class of bug issue geotiff: backend-specific entry points silently drop kwargs of their dispatchers #1561 fixed for the dask and GPU dispatchers.
  • Reject both combinations up front with ValueError, mirroring the wording the dispatcher already uses for other VRT-incompatible kwargs (overview_levels on VRT writes, cog=True on VRT writes). Add regressions for the new error path plus a smoke test that confirms non-VRT sources still accept overview_level.

Fixes #1685. Found during the geotiff API consistency sweep (Cat 5, MEDIUM).

Test plan

  • pytest xrspatial/geotiff/tests/test_open_geotiff_vrt_kwarg_drop_1685.py
  • pytest xrspatial/geotiff/tests/test_polish_1488.py xrspatial/geotiff/tests/test_backend_kwarg_parity_1561.py xrspatial/geotiff/tests/test_gpu_kwarg_rename_1560.py xrspatial/geotiff/tests/test_vrt_backend_coverage_2026_05_11.py (59 tests, all pass)

@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 12, 2026
brendancol added a commit to brendancol/xarray-spatial that referenced this pull request May 12, 2026
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on
to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to
float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped
overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and
xarray-contrib#1689. cuda-validated.
brendancol added a commit to brendancol/xarray-spatial that referenced this pull request May 12, 2026
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on
to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to
float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped
overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and
xarray-contrib#1689. cuda-validated.
brendancol added a commit to brendancol/xarray-spatial that referenced this pull request May 12, 2026
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on
to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to
float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped
overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and
xarray-contrib#1689. cuda-validated.
brendancol added a commit that referenced this pull request May 12, 2026
* Document bigtiff kwarg in to_geotiff docstring (#1683)

The Parameters block jumped from overview_resampling to gpu, omitting
the bigtiff entry that has been on the signature for several releases.
write_geotiff_gpu documents the same kwarg, so callers who learned the
API from the GPU writer and ported a call to to_geotiff had no way to
discover the option from help(to_geotiff). Pin the entry against future
drift with a test that walks the Parameters block and compares it to
inspect.signature().

* Update api-consistency sweep state for geotiff v2 (2026-05-12)

Three MEDIUM findings filed and fixed: #1683 (bigtiff docstring gap on
to_geotiff), #1684 (write_vrt nodata float|None widened to
float|int|None), and #1685 (open_geotiff silently dropped
overview_level / on_gpu_failure on VRT sources). PRs #1686, #1687, and
#1689. cuda-validated.
@brendancol brendancol requested a review from Copilot May 12, 2026 17:56
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

This PR fixes an API-consistency gap in xrspatial.geotiff.open_geotiff where VRT sources previously routed through read_vrt and silently ignored overview_level / on_gpu_failure. It makes those unsupported kwarg combinations fail loudly (with ValueError) and adds regression coverage to prevent future silent kwarg drops.

Changes:

  • Add VRT-specific validation in open_geotiff to reject overview_level and on_gpu_failure before dispatching to read_vrt.
  • Add regression tests ensuring VRT calls raise on unsupported kwargs and that non-VRT .tif sources still accept overview_level.
  • Update the internal API-consistency sweep state CSV entry.

Reviewed changes

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

File Description
xrspatial/geotiff/__init__.py Adds VRT dispatch validation to prevent silent dropping of overview_level / on_gpu_failure.
xrspatial/geotiff/tests/test_open_geotiff_vrt_kwarg_drop_1685.py New regression tests covering the new VRT error paths and a non-VRT smoke check for overview_level.
.claude/sweep-api-consistency-state.csv Updates internal sweep tracking notes for the geotiff module.

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

Comment on lines +614 to +624
# ``read_vrt`` does not accept ``overview_level`` (the VRT XML
# references its own source files; overview selection would need
# to apply to each one). Silently dropping the kwarg was the same
# class of bug issue #1561 fixed for the dask and GPU dispatchers,
# so refuse the combination up front rather than handing the
# caller a full-resolution mosaic with no warning. See issue #1685.
if overview_level is not None:
raise ValueError(
"overview_level is not supported for VRT sources. "
"VRT references its own source files; pass overview_level "
"to open_geotiff on a .tif source, or drop the kwarg.")
Comment on lines +56 to +57
"""``overview_level`` plus ``.vrt`` raises ValueError, not a silent drop."""
with pytest.raises(ValueError, match="overview_level is not supported"):
brendancol added a commit that referenced this pull request May 12, 2026
* Widen write_vrt nodata type hint to accept int (#1684)

write_vrt advertised `nodata: float | None` while the sibling writers
to_geotiff and write_geotiff_gpu accept "float, int, or None" with no
type annotation. Integer sentinels (65535 for uint16, -9999 for int32)
round-trip through the rest of the I/O surface; the float-only hint
was a static-typing trap, not a runtime constraint. Widen to
`float | int | None` on the public wrapper and the internal
_vrt.write_vrt, and document the surface match in both docstrings. Add
a round-trip regression so future drift surfaces.

* Update api-consistency sweep state for geotiff v2 (2026-05-12)

Three MEDIUM findings filed and fixed: #1683 (bigtiff docstring gap on
to_geotiff), #1684 (write_vrt nodata float|None widened to
float|int|None), and #1685 (open_geotiff silently dropped
overview_level / on_gpu_failure on VRT sources). PRs #1686, #1687, and
#1689. cuda-validated.
…#1685)

open_geotiff documents overview_level and on_gpu_failure as supported,
but the VRT dispatch branch routes through read_vrt, whose signature
accepts neither. Callers got full-resolution data (overview_level) or
CPU-decoded output (on_gpu_failure) with no warning. Issue xarray-contrib#1561 fixed
the same class of silent kwarg drop for the dask and GPU dispatchers;
this commit closes the VRT gap by rejecting both combinations up front
with the same wording other VRT-incompatible kwargs already use. Add
regressions for the new error path and a smoke test that confirms
non-VRT sources still accept overview_level.
Addresses Copilot review on PR xarray-contrib#1689. ``overview_level=0`` is documented
as "full resolution" (the default), so passing it on a VRT is
semantically equivalent to omitting the kwarg and should not raise.
The guard now rejects only non-zero overview levels for VRT sources.

The regression test now also covers the ``overview_level=0`` case to
prevent the guard from regressing back to ``is not None``.
@brendancol brendancol force-pushed the deep-sweep-api-consistency-geotiff-2026-05-12-v2-03 branch from 51481d7 to 93cee55 Compare May 12, 2026 18:28
@brendancol brendancol merged commit 5142229 into xarray-contrib:main May 12, 2026
10 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.

geotiff: open_geotiff silently drops overview_level when routing to VRT reader

2 participants