Skip to content

Reconcile COG write stability across registry, contract, and docstring#2520

Merged
brendancol merged 3 commits into
mainfrom
issue-2513
May 27, 2026
Merged

Reconcile COG write stability across registry, contract, and docstring#2520
brendancol merged 3 commits into
mainfrom
issue-2513

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2513.

Summary

The registry, the release contract, and the reference docs already declared COG writes stable under SUPPORTED_FEATURES['writer.cog']. The to_geotiff() docstring disagreed: it put cog=True and overview generation under [advanced] and tagged the cog parameter [advanced].

This PR picks option (a) from the issue. The COG layout is stable. The to_geotiff() docstring now lists cog=True under the [stable] tier bullet with an inline link to SUPPORTED_FEATURES['writer.cog'], and the cog parameter marker flips to [stable]. The overview_levels and overview_resampling knobs stay [advanced] because they map to the separately tracked writer.overviews sub-behaviour. geotiff.rst and geotiff_release_contract.md now spell that split out so the docs page agrees with the docstring.

Four tripwire gates land in test_stable_features.py: writer.cog stays stable, writer.overviews stays advanced, the docstring lists cog=True under [stable], and the overview knobs stay [advanced]. If any of those pins drops, the release gate fails before release.

Backend coverage

Docs and contract only. No code paths touched, no backend matrix to update.

Test plan

  • pytest -q xrspatial/geotiff/tests -m 'not slow' (5917 passed, 74 skipped, 1 xfailed)
  • New tripwire gates pass: pytest xrspatial/geotiff/tests/release_gates/test_stable_features.py -k "writer_cog_stays_stable or writer_overviews_stays_advanced or docstring_marks_cog_stable or docstring_marks_overview_knobs_advanced"

#2513)

SUPPORTED_FEATURES['writer.cog'] in the runtime registry reports
'stable', and the release contract and reference docs agree. The
to_geotiff() docstring did not: it listed cog=True under the
[advanced] tier block and tagged the cog parameter as [advanced].

This picks option (a) from the issue. The COG layout is stable.
Only the pyramid customisation knobs (overview_levels,
overview_resampling) stay advanced, because writer.overviews is
the separately tracked advanced sub-behaviour.

What changed:

to_geotiff docstring: cog=True moves to the [stable] tier bullet
with an inline reference to SUPPORTED_FEATURES['writer.cog'], and
the cog parameter marker flips from [advanced] to [stable]. The
overview_levels and overview_resampling markers stay [advanced],
matching writer.overviews.

docs/source/reference/geotiff.rst: the "Stable COG contract"
section now spells out that the pyramid-customisation knobs stay
advanced under writer.overviews even though the COG layout itself
is stable.

docs/source/reference/geotiff_release_contract.md: the writer.cog
and writer.overviews rows name the split explicitly.

xrspatial/geotiff/tests/release_gates/test_stable_features.py:
four tripwire gates pin the resolution. writer.cog stays stable,
writer.overviews stays advanced, the docstring lists cog=True
under [stable], and overview_levels / overview_resampling stay
[advanced]. If any of those pins drops, the gate fails before
release.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 27, 2026
Copy link
Copy Markdown
Contributor Author

@brendancol brendancol left a comment

Choose a reason for hiding this comment

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

PR Review: Reconcile COG write stability across registry, contract, and docstring

Blockers (must fix before merge)

None. Docs-and-contract reconciliation. The four new tripwire gates pass locally on Python 3.14, and the geotiff suite stays green.

Suggestions (should fix, not blocking)

  • xrspatial/geotiff/tests/release_gates/test_stable_features.py:2657,2704: the new tripwire tests regex against to_geotiff.__doc__. Python 3.13 trims leading whitespace from docstrings at compile time, but Python 3.12 (still supported per setup.cfg's python_requires = >=3.12) does not. The current regexes anchor at column 0 (r"^cog : bool\n \["), which works on 3.13 / 3.14 and breaks on 3.12 because every body line keeps its 4-space indent. PR CI only runs 3.14, so this PR lands green, but a 3.12 user running pytest locally trips a false positive. Wrap the docstring in inspect.getdoc(to_geotiff) (or inspect.cleandoc(to_geotiff.__doc__ or "")) before regexing; that normalises indent across every supported Python.

Nits (optional improvements)

  • xrspatial/geotiff/tests/release_gates/test_stable_features.py:2655,2702: the two docstring tests do a local from xrspatial.geotiff import to_geotiff. The same name is already imported at module scope around line 81. Hoist for consistency with the rest of the file.
  • xrspatial/geotiff/tests/release_gates/test_stable_features.py:2673-2674: the comment "Python strips the common leading indent on __doc__" is only true on 3.13+. Drop or rewrite if you stay on raw __doc__; if you move to inspect.getdoc, the comment goes away anyway.

What looks good

  • The three surfaces (runtime registry, contract md, reference rst) now agree: writer.cog = stable, writer.overviews = advanced. The docstring tier markers match.
  • The "COG layout is stable, pyramid customisation is advanced" split is spelled out in all three places using the same SUPPORTED_FEATURES['writer.overviews'] reference.
  • Function-level [stable] bullet lists cog=True. Per-parameter [stable] marker on cog matches.
  • Four tripwire gates pin every surface, so a future drift trips a release gate instead of shipping silently.
  • No code paths touched; the geotiff suite remains green (5917 passed locally).
  • The release contract's writer.overviews row names both the customisation knobs and the resampling output, so the boundary against writer.cog is unambiguous.

Checklist

  • Algorithm matches reference/paper (N/A, docs only)
  • All implemented backends produce consistent results (N/A, no backend code touched)
  • NaN handling is correct (N/A)
  • Edge cases are covered by tests
  • Dask chunk boundaries handled correctly (N/A)
  • No premature materialization or unnecessary copies (N/A)
  • Benchmark exists or is not needed (not needed)
  • README feature matrix updated (not needed; no new function)
  • Docstrings present and accurate

…#2513)

The two docstring tripwires read to_geotiff.__doc__ and regex
against it. That works on Python 3.13+ (which dedents docstrings
at compile time) but fails on Python 3.12 (still supported per
setup.cfg's python_requires = >=3.12), because every body line
keeps its 4-space source indent and the column-0 anchors miss.

Switch the tests to inspect.getdoc(to_geotiff), which normalises
indent on every supported Python version. PR CI only runs 3.14,
so the difference would not have shown up in CI, but a 3.12 user
running pytest locally would have tripped a false positive.

Also fold the local "from xrspatial.geotiff import to_geotiff"
into the module-scope import already used elsewhere in the file,
and reword the misleading comment about __doc__ indent stripping.
Copy link
Copy Markdown
Contributor Author

@brendancol brendancol left a comment

Choose a reason for hiding this comment

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

PR Review (follow-up after e75bd44)

Blockers

None.

Suggestions

None remaining.

Nits

None remaining.

What looks good

  • The earlier Suggestion is addressed. Both docstring gates now go through inspect.getdoc(to_geotiff), so the regex anchors line up on Python 3.12, 3.13, and 3.14.
  • The duplicate local imports are gone. The tests use the module-scope to_geotiff import at line 81.
  • The misleading "Python strips the common leading indent on __doc__" comment is replaced with a docstring note that explains why inspect.getdoc is used.
  • Tripwire gates still pass locally.
  • No code paths touched. The surface change is still docs and tests only.

Checklist

  • Algorithm matches reference/paper (N/A, docs only)
  • All implemented backends produce consistent results (N/A, no backend code touched)
  • NaN handling is correct (N/A)
  • Edge cases are covered by tests
  • Dask chunk boundaries handled correctly (N/A)
  • No premature materialization or unnecessary copies (N/A)
  • Benchmark exists or is not needed (not needed)
  • README feature matrix updated (not needed; no new function)
  • Docstrings present and accurate

# Conflicts:
#	xrspatial/geotiff/_writers/eager.py
@brendancol brendancol merged commit 47a6ca0 into main May 27, 2026
7 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.

COG write stability contract contradicts to_geotiff() docstring

1 participant