microsoft / PlanetaryComputer

Issues, discussions, and information about the Microsoft Planetary Computer
https://planetarycomputer.microsoft.com/
MIT License
185 stars 10 forks source link

Problem accessing TerraClimate: open_zarr() got unexpected keyword arguments engine #172

Closed tomconte closed 1 year ago

tomconte commented 1 year ago

Hi all, since today we are getting the following error when accessing the TerraClimate dataset:

products/biodiversity/src/stac_data_loader.py:557: in load_data
    ds = xr.open_zarr(mapper, **asset.extra_fields["xarray:open_kwargs"])

[...]

        if kwargs:
>           raise TypeError(
                "open_zarr() got unexpected keyword arguments " + ",".join(kwargs.keys())
            )
E           TypeError: open_zarr() got unexpected keyword arguments engine

It looks like open_zarr() does not like the new argument engine that was added to xarray:open_kwargs?

I added the following line to fix the problem:

asset.extra_fields["xarray:open_kwargs"].pop("engine", None)
TomAugspurger commented 1 year ago

Hi @tomconte, yes the release today adopted a new version of the xarray-assets extension. Sorry for the churn, but you'll want to update your code to use

ds = xr.open_dataset(asset.href, **asset.extra_fields["xarray:open_kwargs"]

See https://planetarycomputer.microsoft.com/docs/overview/changelog#other-dataset-updates. Our example notebook has been updated as well.

TomAugspurger commented 1 year ago

This also highlights the need for something like https://github.com/stac-utils/pystac/issues/846. It'd be easier for a single library to manage all the different ways of specifying these kinds of details than every needing to worry about it.

tomconte commented 1 year ago

Thanks Tom!