xpublish-community / xpublish

Publish Xarray Datasets via a REST API.
https://xpublish.readthedocs.io
Apache License 2.0
168 stars 23 forks source link

Change 'compressor' encoding so that it contains 'id' #270

Open wachsylon opened 6 months ago

wachsylon commented 6 months ago

So this is based on many assumptions that I am too lazy to validate :) but it seems plausible to me and it fixes an issue:

If a .zarray of a variable is retrieved, a pure dict is returned. I am not sure what fastapi is doing with that, but obviously, the return is a JSON. If a compressor is set, I guess the __dict__ representation of it is used.

The problem is, there is a difference between cd and cc, defined as:

import numcodecs
codec = numcodecs.Blosc(cname='zstd', clevel=5, shuffle=1, blocksize=0)
cd=codec.__dict__
cc=codec.get_config()

I assume that we want to have cc because it contains a id keyword. Without this, it is not clear that blosc was actually used.

wachsylon commented 6 months ago

i now see that this is pretty similar to jsonify_zmetadata maybe it is possible to use this as well