-
-
Notifications
You must be signed in to change notification settings - Fork 358
Add registry for chunk key encodings for extensibility #3436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3436 +/- ##
==========================================
- Coverage 94.92% 94.86% -0.06%
==========================================
Files 79 79
Lines 9491 9518 +27
==========================================
+ Hits 9009 9029 +20
- Misses 482 489 +7
🚀 New features to boost your workflow:
|
Note that the current implementation does not use the global config. This means that it only supports a single implementation (registration) for each chunk key encoding 'type' as indicated by the With the entrypoint plugin mechanism this currently doesn't work correctly. It uses the full class path rather than the entrypoint name I will update the registry to bring it in line with how codecs are implemented, with a dict of registries, that map a chunk key encoding type (name) to a registry that contains possibly multiple implementations for that type. |
its implementation indicated by qualname. Set default chunk key encodings implementations for `default` and `v2` in global config.
You don't need to copy the codec registry. A simple |
for context, the codec registry associates multiple codec classes with a single codec identifier because of need specific to codecs (running the same codec algorithm on a CPU vs GPU). Chunk key encodings will never be run on specialized hardware, so we can use a simpler mapping. |
Originally, I implemented it such that it would only allow one implementation, but there were some issues as noted in my other comment. That said, these can be resolved by always using the Regarding different implementations, it doesn't need to be on special hardware, right? One could also make their own implementation, possibly with bindings in a faster language. Not that I think that this would be common for chunk key encodings. Let me know if you want me to revert to the simpeler, one implementation only design. |
This enables users to add additional fields to a custom ChunkKeyEncoding without having to override __init__ and taking care of immutability of the attrs.
Following #3433 (@d-v-b), I have implemented a registry for chunk key encodings. This allows users to subclass
ChunkKeyEncoding
and create their own implementation.The scope of ChunkKeyEncoding.from_dict() function is reduced to what you expect it do: build from a dict. I placed the parsing function in
chunk_key_encodings.py
as it is used in both array and metadata v3 construction. I wasn't sure where else to put it.TODO:
docs/user-guide/*.rst
changes/