Geotiff polish: validation, caching caps, parallelism thresholds, memory guards (#1488)#1493
Merged
brendancol merged 2 commits intomainfrom May 5, 2026
Merged
Geotiff polish: validation, caching caps, parallelism thresholds, memory guards (#1488)#1493brendancol merged 2 commits intomainfrom
brendancol merged 2 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1488.
What's in here
Ten small ergonomic / safety items from the geotiff audit, bundled.
to_geotiffvalidatescompressionup-front instead of letting the error surface from_compression_tag. Same exception class, friendlier traceback.read_geotiff_dask->read_vrtdefensive fallback. No public behavior change.write_vrtdocstring spells outrelative,crs_wkt,nodatainstead of pointing at the internal helper.tiled=Falsewith a non-defaulttile_sizenow warns instead of silently ignoring._mmap_cachegot a soft LRU cap (default 32, configurable viaXRSPATIAL_GEOTIFF_MMAP_CACHE_SIZE). In-use entries are never evicted; only idle ones drop when the cap is exceeded.n_tiles > 1 and tile_pixels > 64*1024regardless of compression. Uncompressed multi-tile reads previously skipped the pool.read_geotiff_dasknow raisesValueError(with a hint) when chunks would produce more than 50,000 dask tasks, instead of silently rescaling at 1M. The hint suggests a chunk size that fits._gpu_decode._check_gpu_memory(required_bytes)callscupy.cuda.runtime.memGetInfo()and raisesMemoryErrorwhen the request exceeds 90% of free VRAM. Wired into the four largest allocations (nvJPEG output buffer, full-image output buffer, tile decode buffer x2).overview_levels=[...]is not capped.Behavior changes
to_geotiff(..., compression=<bad>)now raises with"Unknown compression"rather than"Unsupported compression". Existing test updated to match either phrasing.to_geotiff(..., tiled=False, tile_size=<non-default>)now emits a UserWarning.read_geotiff_daskraises instead of auto-scaling past 50K tasks. Callers relying on the old silent rescale will need to pick chunks explicitly.Test plan
test_polish_1488.py, one cluster per itemtest_unsupported_compression) updated to accept either error phrasing