xcube-dev / xcube

xcube is a Python package for generating and exploiting data cubes powered by xarray, dask, and zarr.
https://xcube.readthedocs.io/
MIT License
195 stars 18 forks source link

The "/statistics" endpoint's query parameter "time" should be optional #1066

Closed forman closed 1 week ago

forman commented 3 weeks ago

Is your feature request related to a problem? Please describe.

Datasets and individual dataset variables published by xcube server are not forced to have a "time" dimension. If the /statistics/{datasetId}/{varName} endpoint is invoked without the "time" parameter, a request error is raised (HTTP status 400):

image

But if the endpoint is invoked with given "time" parameter but the dataset variable is lacking it, an internal error is raised (HTTP status 500):

image

Describe the solution you'd like

  1. Make the query parameter "time" optional for both GET /statistics and POST /statistics endpoints.
  2. Ignore a given "time" query parameter if the variable does not have a time dimension.
  3. Return empty result if "time" query parameter is not given but the variable has a time dimension.

Additional context

After the change xcube Viewer should be adapted to not pass the "time" query parameter".

See also https://github.com/xcube-dev/xcube-viewer/issues/408. See also this for the frontend issue