Spaces:
Running
Running
Nathan Brake
commited on
Throw an error if there's no data, so that the agent can react approp… (#47)
Browse files* Throw an error if there's no data, so that the agent can react appropriately
* raise error instead of assert
src/surf_spot_finder/tools/openmeteo.py
CHANGED
@@ -69,6 +69,8 @@ def get_wave_forecast(lat: float, lon: float, date: str | None = None) -> list[d
|
|
69 |
if date is not None:
|
70 |
date = datetime.fromisoformat(date)
|
71 |
hourly_data = _filter_by_date(date, hourly_data)
|
|
|
|
|
72 |
return hourly_data
|
73 |
|
74 |
|
@@ -110,4 +112,6 @@ def get_wind_forecast(lat: float, lon: float, date: str | None = None) -> list[d
|
|
110 |
if date is not None:
|
111 |
date = datetime.fromisoformat(date)
|
112 |
hourly_data = _filter_by_date(date, hourly_data)
|
|
|
|
|
113 |
return hourly_data
|
|
|
69 |
if date is not None:
|
70 |
date = datetime.fromisoformat(date)
|
71 |
hourly_data = _filter_by_date(date, hourly_data)
|
72 |
+
if len(hourly_data) == 0:
|
73 |
+
raise ValueError("No data found for the given date")
|
74 |
return hourly_data
|
75 |
|
76 |
|
|
|
112 |
if date is not None:
|
113 |
date = datetime.fromisoformat(date)
|
114 |
hourly_data = _filter_by_date(date, hourly_data)
|
115 |
+
if len(hourly_data) == 0:
|
116 |
+
raise ValueError("No data found for the given date")
|
117 |
return hourly_data
|