Cache GEE catalog to avoid repeated network requests#80
Open
mihiarc wants to merge 1 commit intotaraskiba:mainfrom
Open
Cache GEE catalog to avoid repeated network requests#80mihiarc wants to merge 1 commit intotaraskiba:mainfrom
mihiarc wants to merge 1 commit intotaraskiba:mainfrom
Conversation
Previously, the GEE catalog was fetched from GitHub multiple times during normal usage: - On class instantiation (to populate dropdown) - On dropdown value change - On button click / load_gee_as_image() This resulted in 3-4 network requests per extraction operation. Changes: - Add cached catalog functions to common.py using @lru_cache - Add helper functions: get_gee_catalog_as_dict(), get_dataset_type(), get_dataset_url() - Update all 6 modules to use the cached functions - Remove duplicated fetch_geojson() implementations - Add timeout handling for network requests Benefits: - Single network request per session (cached) - Faster widget initialization - Reduced code duplication (-125 lines net) - Better error handling with timeout Also fixes date filtering bug (same as taraskiba#75) in additional locations. Fixes taraskiba#76
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.
Summary
@lru_cachedecorator to cache GEE catalog fetch, avoiding repeated network requestsfetch_geojson()implementations into shared functions incommon.pyProblem
The GEE catalog was being fetched from GitHub multiple times during normal usage:
load_gee_as_image()to determine dataset typeThis resulted in 3-4 network requests per extraction operation, causing:
Solution
Added cached functions to
common.py:Files Changed
skiba/common.pyskiba/point_extraction.pyskiba/aggregated_point_extraction.pyskiba/buffer_coordinates.pyskiba/buffer_and_sample.pyskiba/buffer_method.pyskiba/geojson_buffering.pyNet change: -125 lines (removed duplication)
Additional Improvements
Timeoutexception)Fixes #76