Skip to content

Commit 3bd8a4b

Browse files
committed
Add simple NoDataAvailableError exception for missing data handling
- Introduce a lightweight `NoDataAvailableError` exception to handle cases where no data is available for analysis or plotting. - Add a check after data retrieval in `run_workflow()` to raise a `NoDataAvailableError` if reporting data is empty. This prevents proceeding with empty datasets and ensures graceful failure. Signed-off-by: cyiallou - Costas <[email protected]>
1 parent 44fd7ab commit 3bd8a4b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/frequenz/lib/notebooks/solar/maintenance/solar_maintenance_app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ class SolarAnalysisData:
119119
)
120120

121121

122+
class NoDataAvailableError(Exception):
123+
"""Raised when there is no available data."""
124+
125+
122126
# pylint: disable=too-many-statements, too-many-branches, too-many-locals
123127
async def run_workflow(user_config_changes: dict[str, Any]) -> SolarAnalysisData:
124128
"""Run the Solar Maintenance App workflow.
@@ -142,6 +146,7 @@ async def run_workflow(user_config_changes: dict[str, Any]) -> SolarAnalysisData
142146
`stat_profile_view_col_to_plot`) are hardcoded.
143147
- If the timezone of the data does not match the timezone in the
144148
configuration.
149+
NoDataAvailableError: If no reporting data is available.
145150
"""
146151
config, all_client_site_info = _load_and_validate_config(user_config_changes)
147152

@@ -193,6 +198,9 @@ async def run_workflow(user_config_changes: dict[str, Any]) -> SolarAnalysisData
193198
)
194199
reporting_data_higher_fs = await retrieve_data(reporting_config)
195200

201+
if reporting_data.empty and reporting_data_higher_fs.empty:
202+
raise NoDataAvailableError("No reporting data available. Cannot proceed.")
203+
196204
weather_data = transform_weather_data(
197205
data=weather_data,
198206
weather_feature_names_mapping=config.weather_feature_names_mapping,

0 commit comments

Comments
 (0)