Skip to content

Extracting cache storage#3898

Merged
springfall2008 merged 3 commits intomainfrom
feat/cache_module
May 10, 2026
Merged

Extracting cache storage#3898
springfall2008 merged 3 commits intomainfrom
feat/cache_module

Conversation

@springfall2008
Copy link
Copy Markdown
Owner

No description provided.

@springfall2008 springfall2008 requested review from Copilot and mgazza and removed request for Copilot May 9, 2026 19:01
Copilot AI review requested due to automatic review settings May 10, 2026 10:50
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 extracts cache persistence into a new StorageComponent/StorageLocalFiles backend and migrates several existing “cache to config_root/cache” implementations to use the shared storage abstraction.

Changes:

  • Add a new apps/predbat/storage.py storage component (async save/load/age + expiry metadata + periodic cleanup) and register it in the component registry.
  • Migrate Solcast/Open-Meteo/Forecast.Solar caching in SolarAPI.cache_get_url() and Solcast/Forecast.Solar on-disk caches to use the storage component.
  • Persist/restore GE Cloud settings and FutureRate URL cache via storage; add unit tests for the storage backend and the migrated behaviors.

Reviewed changes

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

Show a summary per file
File Description
requirements.txt Adds aiofiles dependency for async filesystem I/O in the new storage backend.
apps/predbat/storage.py Introduces the storage backend + component wrapper and cache cleanup logic.
apps/predbat/components.py Registers the new storage component in phase 0.
apps/predbat/component_base.py Adds ComponentBase.storage convenience accessor for components.
apps/predbat/solcast.py Switches URL caching and Solcast/Forecast.Solar caches to the storage backend.
apps/predbat/gecloud.py Restores/saves inverter settings + GE URL cache via the storage backend.
apps/predbat/futurerate.py Loads/saves FutureRate URL cache via the storage backend.
apps/predbat/predbat.py Removes legacy futurerate_url_cache initialization from reset state.
apps/predbat/userinterface.py Removes legacy futurerate_url_cache from the debug exclude list.
apps/predbat/unit_test.py Registers the new storage test suite in the main test runner.
apps/predbat/tests/test_storage.py Adds unit tests for storage round-trip, expiry, cleanup, and age semantics.
apps/predbat/tests/test_solcast.py Updates SolarAPI cache tests to use storage rather than direct filesystem JSON.
apps/predbat/tests/test_ge_cloud.py Updates GE cache tests and adds tests for settings save/restore behavior via storage.
apps/predbat/tests/test_futurerate_auto.py Adds tests asserting FutureRate cache load/save via storage.
.cspell/custom-dictionary-workspace.txt Adds aiofiles to the spelling dictionary.

Comment thread apps/predbat/solcast.py
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

Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.

Comment thread apps/predbat/solcast.py
Comment on lines +235 to +238
# Store data in cache with 7-day expiry
if self.storage and data:
expiry = datetime.now(timezone.utc) + timedelta(days=7)
await self.storage.save("solar", hash_key, data, format="json", expiry=expiry)
Comment thread apps/predbat/storage.py
except (ValueError, TypeError):
return None
if dt.tzinfo is None:
dt = dt.replace(tzinfo=timezone.utc)
Comment thread apps/predbat/storage.py
Comment on lines +60 to +61
separators embedded in the identifier.
"""
@springfall2008 springfall2008 merged commit abcca9e into main May 10, 2026
5 checks passed
@springfall2008 springfall2008 deleted the feat/cache_module branch May 10, 2026 13:22
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