openmeteo / enhydris

A database with a web interface for the storage and management of hydro/meteorological measurements and time series
GNU Affero General Public License v3.0
18 stars 11 forks source link

<built-in function is_scalar> returned a result with an error set #499

Closed aptiko closed 11 months ago

aptiko commented 1 year ago
Traceback (most recent call last):
  File "/opt/enhydris-openmeteo/enhydris/models/timeseries.py", line 183, in get_data
    data = self._get_data_from_cache(start_date, end_date)
  File "/opt/enhydris-openmeteo/enhydris/models/timeseries.py", line 196, in _get_data_from_cache
    raise DataNotInCache()

During handling of the above exception (), another exception occurred:
  File "/usr/lib/python3.9/abc.py", line 96, in __instancecheck__
    def __instancecheck__(cls, instance):
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/gunicorn/workers/base.py", line 192, in handle_abort
    sys.exit(1)

The above exception (1) was the direct cause of the following exception:
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/enhydris-openmeteo/enhydris/api/views.py", line 260, in chart
    self._get_chart_data(request, timeseries), many=True
  File "/opt/enhydris-openmeteo/enhydris/api/views.py", line 266, in _get_chart_data
    df = self._drop_nan_rows(timeseries, start_date, end_date)
  File "/opt/enhydris-openmeteo/enhydris/api/views.py", line 270, in _drop_nan_rows
    return timeseries.get_data(
  File "/opt/enhydris-openmeteo/enhydris/models/timeseries.py", line 185, in get_data
    data = self._retrieve_and_cache_data(start_date, end_date)
  File "/opt/enhydris-openmeteo/enhydris/models/timeseries.py", line 225, in _retrieve_and_cache_data
    data = HTimeseries(result_string, default_tzinfo=dt.timezone.utc).data
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/htimeseries/htimeseries.py", line 355, in __init__
    self._read_filelike(data, **kwargs)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/htimeseries/htimeseries.py", line 364, in _read_filelike
    self.data = reader.get_data(tzinfo)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/htimeseries/htimeseries.py", line 404, in get_data
    return TimeseriesRecordsReader(
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/htimeseries/htimeseries.py", line 429, in read
    data = self._read_data_from_stream(f2)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/htimeseries/htimeseries.py", line 452, in _read_data_from_stream
    return self._read_three_columns_from_stream(f)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/htimeseries/htimeseries.py", line 475, in _read_three_columns_from_stream
    result = pd.read_csv(
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/pandas/io/parsers.py", line 676, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/pandas/io/parsers.py", line 454, in _read
    data = parser.read(nrows)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/pandas/io/parsers.py", line 1133, in read
    ret = self._engine.read(nrows)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/pandas/io/parsers.py", line 2037, in read
    data = self._reader.read(nrows)
  File "pandas/_libs/parsers.pyx", line 860, in pandas._libs.parsers.TextReader.read
    <source code not available>
  File "pandas/_libs/parsers.pyx", line 875, in pandas._libs.parsers.TextReader._read_low_memory
    <source code not available>
  File "pandas/_libs/parsers.pyx", line 952, in pandas._libs.parsers.TextReader._read_rows
    <source code not available>
  File "pandas/_libs/parsers.pyx", line 1062, in pandas._libs.parsers.TextReader._convert_column_data
    <source code not available>
  File "pandas/_libs/parsers.pyx", line 2170, in pandas._libs.parsers._apply_converter
    <source code not available>
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/htimeseries/htimeseries.py", line 483, in <lambda>
    "date": lambda x: pd.to_datetime(x).replace(tzinfo=self.tzinfo),
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/pandas/core/tools/datetimes.py", line 756, in to_datetime
    result = convert_listlike(np.array([arg]), format)[0]
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/pandas/core/tools/datetimes.py", line 456, in _convert_listlike_datetimes
    return _box_as_indexlike(result, utc=utc, name=name)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/pandas/core/tools/datetimes.py", line 183, in _box_as_indexlike
    return DatetimeIndex(dt_array, tz=tz, name=name)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/pandas/core/indexes/datetimes.py", line 235, in __new__
    if is_scalar(data):

Exception Type: SystemError at /api/stations/1334/timeseriesgroups/499/timeseries/247/chart/
Exception Value: <built-in function is_scalar> returned a result with an error set
aptiko commented 11 months ago

This issue appeared when asking for /api/stations/1334/timeseriesgroups/499/timeseries/247/chart/. Now, however, that URL works fine. It's hard to know what happened, and looking at the code doesn't help us guess.