-
Notifications
You must be signed in to change notification settings - Fork 33
Support for partial download of zarrs #1596
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: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1240,16 +1240,29 @@ def get_asset_by_path(self, path: str) -> RemoteAsset: | |
| paths (e.g., ``../``) within it. | ||
| """ | ||
| path = self._normalize_path(path) | ||
| try: | ||
| # Weed out any assets that happen to have the given path as a | ||
| # proper prefix: | ||
| (asset,) = ( | ||
| a for a in self.get_assets_with_path_prefix(path) if a.path == path | ||
| ) | ||
| except ValueError: | ||
| raise NotFoundError(f"No asset at path {path!r}") | ||
| else: | ||
| return asset | ||
| # Weed out any assets that happen to have the given path as a | ||
| # proper prefix: | ||
| assets = [a for a in self.get_assets_with_path_prefix(path) if a.path == path] | ||
| if assets: | ||
| if len(assets) > 1: | ||
| lgr.warning( | ||
| "Multiple assets found at path %r; returning the first one", | ||
| path, | ||
| ) | ||
| asset = assets[0] | ||
| elif not assets: | ||
| zarr_suf = ".zarr/" | ||
| if (zarr_suf in path) and (zarr_suffix_idx := path.index(zarr_suf)): | ||
| # If path ends with .zarr/, we might have a zarr asset without | ||
| # a trailing slash in the path. Try again: | ||
| zarr_path_len = zarr_suffix_idx + len(zarr_suf) | ||
| zarr_path = path[: zarr_path_len - 1] # -1 for trailing / | ||
| subpath = path[len(zarr_path) :] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have several issues with this:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I agree that dealing with |
||
| asset = self.get_asset_by_path(zarr_path) | ||
| asset.subpath = subpath | ||
| else: | ||
| raise NotFoundError(f"No asset at path {path!r}") | ||
| return asset | ||
|
|
||
|
|
||
| def download_directory( | ||
| self, | ||
|
|
@@ -1378,6 +1391,8 @@ class BaseRemoteAsset(ABC, APIBase): | |
| identifier: str = Field(alias="asset_id") | ||
| #: The asset's (forward-slash-separated) path | ||
| path: str | ||
| #: The path within the asset, as e.g. path in a zarr/ | ||
| subpath: str | None = Field(default=None) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like the idea of a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I also disliked it a little but it is already quite a hierarchy of classes there leading to nearly combinatorial explosion. If you see a sensible way, e.g. through adding a single extra class - please go ahead.
yarikoptic marked this conversation as resolved.
Outdated
|
||
| #: The size of the asset in bytes | ||
| size: int | ||
| #: The date at which the asset was created | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
.ngff/?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, should also be supported