openclimatefix/pv-site-api

Forecast route breaking on certain site_uuid(s)

Closed this issue · 5 comments

Describe the bug

Site 12e2d399-db22-45e6-a3f5-ff1a83498773 seems to cause an Internal Server Error when a forecast is requested

To Reproduce

Steps to reproduce the behavior:

Calling the 53 site_uuids before this (in the order they come from API) is all good, getting actuals and forecasts.

Expected behavior

Should return forecasts as the other sites do currently.

Additional context

Initially found through Frontend UI calls, and then checked/confirmed through Swagger.

@simlmx would you have time to look at this? If not I can tomorrow

For both queries I see this error in the logs:

2023-03-23T09:10:51.776-04:00 | nowcasting_api \| File "/app/./pv_site_api/_db_helpers.py", line 105, in _forecast_rows_to_pydantic
-- | --
  | 2023-03-23T09:10:51.776-04:00 | nowcasting_api \| SiteForecastValues(
  | 2023-03-23T09:10:51.776-04:00 | nowcasting_api \| File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
  | 2023-03-23T09:10:51.776-04:00 | nowcasting_api \| raise validation_error
  | 2023-03-23T09:10:51.776-04:00 | nowcasting_api \| pydantic.error_wrappers.ValidationError: 1 validation error for SiteForecastValues
  | 2023-03-23T09:10:51.776-04:00 | nowcasting_api \| expected_generation_kw
  | 2023-03-23T09:10:56.249-04:00 | nowcasting_api \| ensure this value is greater than or equal to 0 (type=value_error.number.not_ge; limit_value=0)

We restrict the values to "greater or equal to 0.". Maybe there is a rounding error? This should probably be a warning and we should clip it to 0.

I'll fix it!

Yea clip to 0 would be great

I did find negative values in the database. Too big to be rounding errors but they were very close to zero (all greater than -0.001). Some artifact of the modelling specifics I guess. I still think clipping + warning should fix it. If we end up with too many warnings we can always investigate further.

If its one warning per sites I think it's ok. If it s awarning per target time then I think its too much. Similar experiecne with Nowcasting project