Make ObjectStore backend generic over any obspec store#3698
Open
kylebarron wants to merge 2 commits intozarr-developers:mainfrom
Open
Make ObjectStore backend generic over any obspec store#3698kylebarron wants to merge 2 commits intozarr-developers:mainfrom
kylebarron wants to merge 2 commits intozarr-developers:mainfrom
Conversation
Member
|
+1 Xarray could make use of this. (When reading non-icechunk stores - icechunk already has a caching layer) |
Contributor
Author
|
I'm not sure where the other locations are where I need to define obspec as a dependency |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #1661 we merged an Obstore-based backend. It sounds like the Obstore backend has become very popular, and @maxrjones found that, at least in some situations, the Obstore backend can be significantly faster.
One problem with the Obstore backend, however, is that it's strictly tied to Obstore. The type hinting and runtime behavior all require exact instances from the Obstore package.
But very often people might want to insert some middleware.
The goal of Obspec is to define generic protocols to cleanly enable this. As described in the initial release post from last summer, Obspec should allow downstream libraries to depend on a protocol-based API that works with any implementation that provides the given signature.
E.g. if you think of the simplest pseudocode example of a cache:
Then if a function expects an object implementing
GetRange:Then now you can pass in either the raw obstore backend or the backend wrapped by the cache:
This architecture is much more tractable for end users than if Obstore implemented its own caching natively. Since users have full access to the cache (i.e. it isn't hidden away inside Rust), users can check methods of
SimpleCacheto track how much memory the cache is using and to manually evict cache items if they wanted.@maxrjones has been starting to collect utilities around obspec in https://github.com/virtual-zarr/obspec-utils.
This is backwards-compatible (at least if you ignore the obstore version bump from 0.5.1 — released March 2025 — to 0.7.0 — released June 2025).
Implementation notes
Exceptionsin the obspec docs, the workaround I chose is to use well-defined names, andmap_exceptionwill convert any external exceptions to exceptions subclassing fromobspec.exceptions.TODO:
docs/user-guide/*.mdchanges/