Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR fixes an adjusted-PV failure path that returned False after an unexpected cached-model load error, causing a later Series access failure. It now returns the original unadjusted PV forecast, documents the contract, and updates the existing regression test to verify the fallback, logging, and absence of prediction. Flow diagram for adjusted PV forecast fallbackflowchart TD
A[adjust_pv_forecast] --> B{Cached model load}
B -->|Success| C[adjust_pv_forecast_predict]
B -->|Unexpected exception| D[Return original p_pv_forecast]
D --> E[_prepare_dayahead_optim]
E --> F[p_pv_forecast.values]
C --> E
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This branch has not been deployed
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
Fixes #1144.
adjust_pv_forecast()is declared to return apd.Series, and its existing handled failure paths preserve the original unadjusted PV forecast when the optional adjustment layer cannot be applied.The generic cached-model load exception was the outlier: it returned boolean
False, which then reached_prepare_dayahead_optim()and failed later atp_pv_forecast.values.This PR keeps the adjusted-PV contract consistent by:
p_pv_forecaston an unexpected cached-model load exception;pd.Seriesfallback and verify prediction is not attempted;Why this shape
This deliberately does not add caller-side boolean handling, a new return type, retry/state machinery, a configuration flag, or optimiser changes.
The base PV forecast is already valid at this point, and the surrounding adjusted-PV failure paths already fall back to it when the optional adjustment layer cannot be applied.
No configuration schema, default, API parameter, cookbook recipe, study case, optimiser, or Home Assistant production changes are required.
Reproducer
Before this change:
adjust_pv_forecast()returnsFalse.None.p_pv_forecast.valuesthen raisesAttributeError: 'bool' object has no attribute 'values'.The existing generic-exception regression now verifies the corrected fallback contract.
Validation
Validated head:
d270bbc431d3f775384bbc2b9f5e5c20a24732ccGitHub Actions on that exact head:
Independent Windows validation also completed:
The independent run initially exposed the pre-existing generic-exception test's old
Falseassertion. Rather than adding a duplicate regression, this PR updates that existing test to the correctedpd.Seriescontract.The Sphinx warnings observed during the independent build are pre-existing and outside the adjusted-PV documentation changed here.
Summary by Sourcery
Preserve a valid unadjusted PV forecast when adjusted-PV model loading fails unexpectedly.
Bug Fixes:
Enhancements:
Documentation:
Tests: