You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For me it's a problem because I can't use AWS lambda functions with the lithops serverless framework. My understanding is that pickleability is something that zarr-python tests it can do, so it's inconsistent that numcodecs can't.
The problem seems to be this weird dynamic creation of codec classes. Presumably if numcodecs just defined these classes in a more conentional static way then they would be pickleable.
def_make_bytes_bytes_codec(codec_name: str, cls_name: str) ->type[_NumcodecsBytesBytesCodec]:
# rename for class scope_codec_name=CODEC_PREFIX+codec_nameclass_Codec(_NumcodecsBytesBytesCodec):
codec_name=_codec_namedef__init__(self, **codec_config: JSON) ->None:
super().__init__(**codec_config)
_Codec.__name__=cls_namereturn_Codec
It defines a class inside function scope, but this approach is not needed to solve the underlying problem. As this function gets called fewer than 10 times, we could instead have fewer than 10 separate normal class definitions. That would be my recommended short-term fix.
As this function gets called fewer than 10 times, we could instead have fewer than 10 separate normal class definitions. That would be my recommended short-term fix.
...
we could also use init_subclass and make the codec name a parameter of the class definition.
I'm happy to submit a PR to do this - I had to make a janky branch to get what I'm working on to work anyway - I might as well turn it into a proper PR.
Activity
d-v-b commentedon Apr 23, 2025
is it OK if I transfer this issue to numcodecs?
jakirkham commentedon Apr 23, 2025
Probably need to use
cloudpickle. Did you already try?Or is this coming from some other Zarr code path?
Can't comment on Numcodecs Zarr 3 code as I haven't been involved in this
d-v-b commentedon Apr 23, 2025
@jakirkham the cause is this function:
It defines a class inside function scope, but this approach is not needed to solve the underlying problem. As this function gets called fewer than 10 times, we could instead have fewer than 10 separate normal class definitions. That would be my recommended short-term fix.
d-v-b commentedon Apr 23, 2025
we could also use
__init_subclass__and make the codec name a parameter of the class definition.jakirkham commentedon Apr 23, 2025
Yes I understand. Read the same code. This is the kind of thing
cloudpicklehandles routinelyThat said, Idk why we went with that design choice. This is what I mean by I cannot comment on why that was added that way
d-v-b commentedon Apr 23, 2025
@TomNicholas i transferred this to numcodecs, because it requires changes to numcodecs code.
TomNicholas commentedon Apr 23, 2025
I'm happy to submit a PR to do this - I had to make a janky branch to get what I'm working on to work anyway - I might as well turn it into a proper PR.
d-v-b commentedon Apr 23, 2025
that would be great @TomNicholas, feel free to reach out if you want any pointers.