opendatacube / datacube-ows

Open Data Cube Open Web Services
Other
70 stars 37 forks source link

core.py:556: UserWarning: Converting non-nanosecond precision datetime values to nanosecond precision. #1038

Closed pjonsson closed 3 months ago

pjonsson commented 4 months ago

The error was seen when running datacube-ows, but https://github.com/opendatacube/datacube-core/blob/ff0d0b7e6fa5b966b024c2414d4ec968c09e0fc1/datacube/api/core.py#L556 seems to be in this repository, so creating the issue here. Feel free to move it if it belongs elsewhere.

Expected behaviour

No warnings about converting non-nanosecond precision datetime values to nanosecond precision.

Actual behaviour

Between 22:06:30 and 22:14:30 the other evening, I got 2708 of these log messages from datacube-ows:

/usr/local/lib/python3.10/dist-packages/datacube/api/core.py:556: UserWarning: Converting non-nanosecond precision datetime values to nanosecond precision. This behavior can eventually be relaxed in xarray, as it is an artifact from pandas which is now beginning to support non-nanosecond precision values. This warning is caused by passing non-nanosecond np.datetime64 or np.timedelta64 values to the DataArray or Variable constructor; it can be silenced by converting the values to nanosecond precision ahead of time.
  sources = xarray.DataArray(data,

There are other similar spikes in log messages containing this warning, so it is not a one-off.

Steps to reproduce the behaviour

Unknown.

Environment information

Open Data Cube core, version 1.8.19

Not sure what the question means, datacube-docker v0.3.3, or the datacube-ows-1.8.41 container?

CC to @SpacemanPaul in case this is datacube-ows-related.

SpacemanPaul commented 4 months ago

Ultimately it's an xarray issue - but the best place for a workaround in this case is probably ows.

Yeah, it's definitely OWS. I've already fixed in the (ows) 1.9 branch but I'm going to have to port it to 1.8 as well.

SpacemanPaul commented 4 months ago

This is fixed in the 1.9 branch, but that fix needs to back-ported to 1.8.

pjonsson commented 3 months ago

Unfortunately I don't think this is fixed, here's the log right after starting:

[2024-08-01 12:30:15,368] [WARNING] Environment variable $AWS_DEFAULT_REGION not set.  (This warning can be ignored if all data is stored locally.)
[2024-08-01 12:30:15,456] [WARNING] Environment variable $AWS_DEFAULT_REGION not set.  (This warning can be ignored if all data is stored locally.)
[2024-08-01 12:30:15,464] [WARNING] Environment variable $AWS_DEFAULT_REGION not set.  (This warning can be ignored if all data is stored locally.)
/usr/local/lib/python3.10/dist-packages/datacube/api/core.py:556: UserWarning: Converting non-nanosecond precision datetime values to nanosecond precision. This behavior can eventually be relaxed in xarray, as it is an artifact from pandas which is now beginning to support non-nanosecond precision values. This warning is caused by passing non-nanosecond np.datetime64 or np.timedelta64 values to the DataArray or Variable constructor; it can be silenced by converting the values to nanosecond precision ahead of time.
  sources = xarray.DataArray(data,
/usr/local/lib/python3.10/dist-packages/datacube/api/core.py:556: UserWarning: Converting non-nanosecond precision datetime values to nanosecond precision. This behavior can eventually be relaxed in xarray, as it is an artifact from pandas which is now beginning to support non-nanosecond precision values. This warning is caused by passing non-nanosecond np.datetime64 or np.timedelta64 values to the DataArray or Variable constructor; it can be silenced by converting the values to nanosecond precision ahead of time.
  sources = xarray.DataArray(data,

and then many more of the warning messages. And this is with the latest release image:

ows@897dd7e40a55:~$ datacube-ows-cfg --version
Open Data Cube Open Web Services (datacube-ows) version 1.8.42
SpacemanPaul commented 3 months ago

I'll have another look.