Skip to content

fix: CLI broken imports and GEE tile orientation contract#83

Merged
Dinghye merged 2 commits into
mainfrom
flip
May 15, 2026
Merged

fix: CLI broken imports and GEE tile orientation contract#83
Dinghye merged 2 commits into
mainfrom
flip

Conversation

@Dinghye
Copy link
Copy Markdown
Collaborator

@Dinghye Dinghye commented May 15, 2026

Summary

  • Fix ModuleNotFoundError when importing rs_embed.cli
  • Clarify and enforce north-up orientation contract across all GEE fetch paths
  • Add orientation regression test for _fetch_all_bands_impl

Refactor — GEE tile orientation

Previously, GEEProvider.fetch_array_chw returned south-up raw data and the flip was applied by its caller (_fetch_provider_array_chw_with_bbox_fallback). This was a leaky abstraction: any subclass overriding fetch_array_chw had to know to return south-up or risk being flipped twice.

fetch_array_chw now applies _flip_sample_tile_y internally and contracts to return north-up CHW. The caller no longer flips.

The _sample_image_bands_raw_chw docstring documents why no flip is needed there: reproject(crs=..., scale=...) without .clip() already produces north-up rows from GEE, and adding .clip() would silently invert the row order and break the multiframe (TCHW) path.

Testing

Fake provider fetch_array_chw implementations in test_api_helpers.py updated to return north-up data directly, matching the new contract; 3 test functions renamed to remove references to "flipping south-up tiles"

test_gee_provider.py: added test_fetch_all_bands_impl_passes_through_gee_row_order to lock in the pass-through behaviour of _fetch_all_bands_impl and document that its north-up guarantee comes from GEE's empirical API behaviour, not from Python-level normalization

  • I ran the relevant tests locally.
  • I updated docs for user-facing behavior changes.
  • I updated CHANGELOG.md for user-facing API, model, semantic, or installation changes.
  • This PR does not need a changelog entry.

Notes

Anything reviewers should know about scope, tradeoffs, or follow-up work.

Copy link
Copy Markdown

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

Fixes broken CLI imports and tightens the orientation contract for GEE tile fetches. Previously GEEProvider.fetch_array_chw returned south-up data and relied on its caller (_fetch_provider_array_chw_with_bbox_fallback) to apply _flip_sample_tile_y, which was a leaky abstraction. The flip now happens inside fetch_array_chw, the wrapper no longer flips, and a regression test pins down the (already north-up) pass-through behaviour of _fetch_all_bands_impl.

Changes:

  • Move _flip_sample_tile_y invocation into GEEProvider.fetch_array_chw; remove the duplicate flip from _fetch_provider_array_chw_with_bbox_fallback.
  • Document the orientation contract in fetch_array_chw, _sample_image_bands_raw_chw, and _flip_sample_tile_y; warn against adding .clip() to the multiframe path.
  • Update test fakes to produce north-up data, rename three tests accordingly, and add test_fetch_all_bands_impl_passes_through_gee_row_order.

Reviewed changes

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

Show a summary per file
File Description
src/rs_embed/providers/gee.py fetch_array_chw now flips internally and documents the north-up contract; comment added at _fetch_all_bands_impl reproject call.
src/rs_embed/providers/gee_utils.py Caller stops flipping; new docstrings on _sample_image_bands_raw_chw and _flip_sample_tile_y.
tests/test_api_helpers.py Fake providers updated to emit north-up rows; three tests renamed to drop "south-up" wording.
tests/test_gee_provider.py New regression test asserting _fetch_all_bands_impl preserves GEE's row order.
CHANGELOG.md Documents CLI import fix and the tightened fetch_array_chw contract.

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

Comment on lines +407 to +418
"""Flip the penultimate (height) axis of a CHW or TCHW array from south-up to north-up.

Called by ``_fetch_provider_array_chw_with_bbox_fallback`` (the single-frame
leaf-fetch layer) to normalise the raw south-up output of
``GEEProvider.fetch_array_chw``. ``fetch_array_chw`` uses
``ee.Projection.atScale() + .clip(region)`` before ``sampleRectangle``,
which causes GEE to return rows in south-up order.

``_sample_image_bands_raw_chw`` uses a different call pattern
(``reproject(crs=..., scale=...)`` **without** clip) that already returns
north-up rows from GEE; applying this flip there would invert those tiles.
"""
@Dinghye Dinghye merged commit d8fc244 into main May 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants