geobeyond / Arpav-PPCV-backend

Backend di Piattaforma Proiezioni Climatiche per il Nord-Est.
Creative Commons Attribution 4.0 International
0 stars 1 forks source link

API error when retrieving related station data #155

Closed ricardogsilva closed 4 months ago

ricardogsilva commented 4 months ago

This is a fragment of the logs:

INFO:     79.26.55.181:0 - "GET /api/v2/coverages/time-series/tas_annual_absolute_model_ensemble-rcp26?coords=POINT(12.1983%2045.8414)&datetime=..%2F..&include_coverage_data=true&coverage_data_smoothing=NO_SMOOTHING&coverage_data_smoothing=LOESS_SMOOTHING&coverage_data_s
moothing=MOVING_AVERAGE_11_YEARS&include_coverage_uncertainty=true&include_coverage_related_data=true&include_observation_data=true&observation_data_smoothing=NO_SMOOTHING&observation_data_smoothing=MOVING_AVERAGE_5_YEARS HTTP/1.1" 500 Internal Server Error              
ERROR:    Exception in ASGI application                                                                                                                                                                                                                                        
Traceback (most recent call last):          

...
File "/home/appuser/app/arpav_ppcv/webapp/api_v2/routers/coverages.py", line 411, in get_time_series                                                                                                                                                                         
    time_series = operations.get_coverage_time_series(
  File "/home/appuser/app/arpav_ppcv/operations.py", line 230, in get_coverage_time_series                                                                                                                                                                                     
    data_ = _process_seasonal_station_data(                      
  File "/home/appuser/app/arpav_ppcv/operations.py", line 336, in _process_seasonal_station_data                                                                                                                                                                               
    df = df[["value", "season", "year"]]              
  File "/home/appuser/.cache/pypoetry/virtualenvs/arpav-ppcv-backend-f8CPI8sp-py3.10/lib/python3.10/site-packages/pandas/core/frame.py", line 3811, in __getitem__             
    indexer = self.columns._get_indexer_strict(key, "columns")[1]
  File "/home/appuser/.cache/pypoetry/virtualenvs/arpav-ppcv-backend-f8CPI8sp-py3.10/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 6108, in _get_indexer_strict
    self._raise_if_missing(keyarr, indexer, axis_name)                                                                                                                                                                                                                         
  File "/home/appuser/.cache/pypoetry/virtualenvs/arpav-ppcv-backend-f8CPI8sp-py3.10/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 6171, in _raise_if_missing
    raise KeyError(f"{not_found} not in index")
KeyError: "['season'] not in index"                           
ricardogsilva commented 4 months ago

Sample dev request:

http localhost:8877/api/v2/coverages/time-series/tas_annual_absolute_model_ensemble-rcp26 \
  "coords==POINT(12.1983 45.8414)" \
  datetime=="../.." \
  include_coverage_data==true \
  coverage_data_smoothing==NO_SMOOTHING \
  coverage_data_smoothing==LOESS_SMOOTHING \
  coverage_data_smoothing==MOVING_AVERAGE_11_YEARS \
  include_coverage_uncertainty==true \
  include_coverage_related_data==true \
  include_observation_data==true \
  observation_data_smoothing==NO_SMOOTHING \
  observation_data_smoothing==MOVING_AVERAGE_5_YEARS
ricardogsilva commented 4 months ago

This is manifesting when trying to access yearly observation data, which is a type of data that had not been implemented in the original PR.