-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Added info for Group and Array #2400
base: main
Are you sure you want to change the base?
Conversation
src/zarr/_info.py
Outdated
return template.format(**dataclasses.asdict(self)) | ||
|
||
|
||
def human_readable_size(size: int) -> str: |
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.
This was taken from the 2.x implementation.
def info(self) -> ArrayInfo: | ||
return self._info() | ||
|
||
async def info_complete(self) -> ArrayInfo: |
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.
Maybe we just don't have this in the API till we implement it (since it's new).
else: | ||
kwargs["codecs"] = str(self.metadata.codecs) | ||
kwargs["data_type"] = str(self.metadata.data_type) | ||
# just regular? |
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.
Need to figure out what to do here for other chunking types.
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.
until we have other chunk grid types, I'd say we can either raise an error here (my preference) or leave this field null.
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.
Looks good. A few questions after looking at the initial implementation.
@@ -38,6 +39,7 @@ | |||
"AsyncArray", | |||
"AsyncGroup", | |||
"Group", | |||
"GroupInfo", |
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.
Can you explain why we want to put this in the user API?
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.
I think any object that a user can get through a public API (like zarr.group().info
) should be part of the API somewhere, if only to enable things like static typing without using private imports.
I don't have a preference for whether it's in the top-level API like I've added here, or some submodule.
else: | ||
kwargs["codecs"] = str(self.metadata.codecs) | ||
kwargs["data_type"] = str(self.metadata.data_type) | ||
# just regular? |
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.
until we have other chunk grid types, I'd say we can either raise an error here (my preference) or leave this field null.
) | ||
@property | ||
def info(self) -> ArrayInfo: | ||
return self._async_array.info |
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.
please add docstrings here and in info_complete
Quick pass at adding
.info
to Group and Array. Like 2.x,info
is a property, but it will only contain information that's known statically. I've added aGroup.info_complete
method that actually calls the store to get dynamic information (for group this is children).I've punted on a similar
Array.info_complete
. For that, we'll need to expand the Store ABC to give us annbytes
method to get the size of the array in bytes. Maybe similar for the actual number of chunks written. Doable, but separate from this PR I think .Closes #2135