Skip to content

geotiff: writers return the written path (#1938)#1942

Merged
brendancol merged 1 commit into
mainfrom
rockout-api-consistency-low-geotiff-2026-05-15-02
May 15, 2026
Merged

geotiff: writers return the written path (#1938)#1942
brendancol merged 1 commit into
mainfrom
rockout-api-consistency-low-geotiff-2026-05-15-02

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • to_geotiff and write_geotiff_gpu returned None while write_vrt returned str (the path written). The drift broke mypy consumers handling the three writers uniformly and made the Sphinx-rendered docs surface inconsistent.
  • Make to_geotiff and write_geotiff_gpu return the path argument: a str for filesystem paths, the file-like object for BytesIO destinations. The change is additive (callers that discarded the previous None are unaffected) and lets callers chain a write into a read.
  • write_vrt's existing str contract is preserved.

Closes #1938.

Test plan

  • pytest xrspatial/geotiff/tests/test_writer_return_path_1938.py -x -q (8 passed, GPU test skipped without cupy)
  • pytest xrspatial/geotiff/tests/test_writer.py xrspatial/geotiff/tests/test_writer_matrix.py xrspatial/geotiff/tests/test_signature_parity_1631.py xrspatial/geotiff/tests/test_signature_annotations_1654.py xrspatial/geotiff/tests/test_signature_annotations_1705.py xrspatial/geotiff/tests/test_to_geotiff_allow_internal_only_jpeg_parity.py xrspatial/geotiff/tests/test_vrt_write.py xrspatial/geotiff/tests/test_streaming_write.py -q (176 passed)

Copilot AI review requested due to automatic review settings May 15, 2026 14:39
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 15, 2026
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 aligns the GeoTIFF writer entry points’ return values so callers (and generated docs/type-checkers) can treat to_geotiff, write_geotiff_gpu, and write_vrt uniformly by returning the destination they wrote to.

Changes:

  • Update to_geotiff to return the provided path (string path or file-like object) instead of None.
  • Update write_geotiff_gpu to return the provided path and document the return contract.
  • Add a regression test covering writer return values and pinned return annotations/signatures (with GPU runtime asserted only when cupy+CUDA is available).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
xrspatial/geotiff/_writers/eager.py Changes to_geotiff to return path across all successful write paths and documents the return value.
xrspatial/geotiff/_writers/gpu.py Changes write_geotiff_gpu return type/behavior to return path and documents the new return contract.
xrspatial/geotiff/tests/test_writer_return_path_1938.py Adds regression coverage ensuring writers don’t regress to returning None and that return annotations remain consistent.

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

Comment on lines 45 to 47
bigtiff: bool | None = None,
max_z_error: float = 0.0,
streaming_buffer_bytes: int = 256 * 1024 * 1024,
to_geotiff and write_geotiff_gpu returned None while write_vrt returned
str. The drift broke mypy consumers who handled the three writers
uniformly and made the Sphinx-rendered docs surface inconsistent.

Make to_geotiff and write_geotiff_gpu return the path argument (a str
for filesystem paths, the file-like object for BytesIO destinations).
The change is additive: existing callers that discarded the previous
None return are unaffected, and chained writes (path = to_geotiff(da,
out); da2 = open_geotiff(path)) work without round-tripping through a
variable.

write_vrt's existing str return is preserved.

Regression test pins the runtime return value for to_geotiff and
write_vrt across str + BytesIO + COG + dask-streaming destinations,
plus a GPU branch gated on cupy+CUDA. A signature-level assertion pins
the return annotations of all three writers so a future change cannot
silently revert the contract.
@brendancol brendancol force-pushed the rockout-api-consistency-low-geotiff-2026-05-15-02 branch from 5f75ca9 to 3999ffd Compare May 15, 2026 14:51
@brendancol brendancol merged commit 1f3ee42 into main May 15, 2026
1 of 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: writer return-type drift (to_geotiff/write_geotiff_gpu return None, write_vrt returns str)

2 participants