Skip to content

Commit 7dc0676

Browse files
committed
wcs?_utils: wrap to_netcdf in bytes()
Xarray 2025.9.0 returns a memoryview instead of bytes when the path argument is None, so wrap the call in bytes() and adjust the type signature to correspond to that.
1 parent aa63c1c commit 7dc0676

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

datacube_ows/wcs1_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import xarray
1111
import xarray as xr
1212
from affine import Affine
13-
from dask.delayed import Delayed
1413
from dateutil.parser import parse
1514
from odc.geo import geom
1615
from odc.geo.geobox import GeoBox
@@ -523,7 +522,7 @@ def get_tiff(req, data: xr.Dataset) -> bytes:
523522
return memfile.read()
524523

525524

526-
def get_netcdf(req, data: xr.Dataset) -> bytes | Delayed | None:
525+
def get_netcdf(req, data: xr.Dataset) -> bytes:
527526
# Cleanup dataset attributes for NetCDF export
528527
data.attrs["crs"] = req.response_crsid
529528
for _, v in data.data_vars.items():
@@ -536,4 +535,4 @@ def get_netcdf(req, data: xr.Dataset) -> bytes | Delayed | None:
536535
del data["time"].attrs["units"]
537536

538537
# And export to NetCDF
539-
return data.to_netcdf()
538+
return bytes(data.to_netcdf())

datacube_ows/wcs2_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,4 @@ def get_netcdf(request, data: xr.Dataset, crs) -> bytes:
431431
del data["time"].attrs["units"]
432432

433433
# And export to NetCDF
434-
return data.to_netcdf()
434+
return bytes(data.to_netcdf())

0 commit comments

Comments
 (0)