Skip to content

General refactor load stac#1484

Draft
JeroenVerstraelen wants to merge 9 commits into
masterfrom
general-refactor-load-stac
Draft

General refactor load stac#1484
JeroenVerstraelen wants to merge 9 commits into
masterfrom
general-refactor-load-stac

Conversation

@JeroenVerstraelen

Copy link
Copy Markdown
Contributor

No description provided.

 The original from_date, to_date calculation was implemented for this issue:
 #609

 However, these dates are rarely used inside the JVM. They are only used to query the OpenSearch client and sometimes to set the layer metadata. The FixedOpenSearchClient ignores the dateRange parameter completely so only the temporal extent of the layer metadata is relevant to us. We just need to ensure our GeopysparkCubeMetadata is correct and we can pass its temporal_extent to scala.

 The only source of truth for the GeopysparkCubeMetadata should be the temporal extent of the STAC items we extracted. If for some reason these do not give us a temporal extent then we either have an empty datacube or faulty items. In both cases it should be okay to fallback to the user requested temporal extent. However I feel like we should handle 'faulty' features a bit more explicitly. Since for calculating the temporal extent of an ItemCollection we use `item.properties.get("start_datetime")` and `"end_datetime` but when constructing the OpenSearch Features we send to the JVM we use `itm.properties.get("datetime")`. So what happens when the STAC items have a datetime but no start and end datetime, then we construct a RasterCube with valid dates but our python metadata is out of sync.
Copy original load_stac.py to load_stac_legacy.py to enable golden
master testing during refactor. This file will be used as the reference
implementation to ensure behavioral equivalence.
Split load_stac.py into focused modules:
- stac/exceptions.py: NoDataAvailableException, LoadStacException
- stac/fixed_features_open_search_client.py: OpenSearch client handling
- stac/item_collection.py: ItemCollection, PropertyFilter, ItemDeduplicator,
  and related STAC item processing

This modularization improves code organization and maintainability
while preserving all original functionality.
Major changes:
- Import STAC classes from new stac/ module instead of defining locally
- Simplify load_stac.py by ~800 lines through extraction
- Maintain identical public API and behavior
- All original functionality preserved, just reorganized

This refactor makes the codebase more maintainable and testable
while ensuring no behavioral changes to the load_stac process.
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