Skip to content
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

adding datastore size to iohub info #248

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions iohub/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,21 @@ def print_info(path: StrOrBytesPath, verbose=False):
print("Zarr hierarchy:")
reader.print_tree()
positions = list(reader.positions())
total_GB_uncompressed = (
len(positions) * (positions[0][1][0].nbytes) / 1e9
Copy link
Collaborator

@ziw-liu ziw-liu Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis would be confusing if showing 0.00 GB for <10 MB. Maybe try to mimic the behavior of du -h?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zarr also does this: https://zarr.readthedocs.io/en/v2.18.3/_autoapi/zarr.core.Array.html#zarr.core.Array.info

import zarr
z = zarr.zeros(1000000, chunks=100000, dtype='i4')
z.info
Type               : zarr.core.Array
Data type          : int32
Shape              : (1000000,)
Chunk shape        : (100000,)
Order              : C
Read-only          : False
Compressor         : Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0)
Store type         : zarr.storage.KVStore
No. bytes          : 4000000 (3.8M)
No. bytes stored   : 320
Storage ratio      : 12500.0
Chunks initialized : 0/10

)
msgs.append(f"Positions:\t\t {len(positions)}")
msgs.append(f"Chunk size:\t\t {positions[0][1][0].chunks}")
msgs.append(
f"Uncompressed size [GB]:\t\t {total_GB_uncompressed:.2f}"
)
else:
total_GB_uncompressed = reader["0"].nbytes / 1e9
msgs.append(f"(Z, Y, X) scale (um):\t {tuple(reader.scale[2:])}")
msgs.append(f"Chunk size:\t\t {reader['0'].chunks}")
msgs.append(
f"Uncompressed size [GB]:\t\t {total_GB_uncompressed:.2f}"
)
if verbose:
msgs.extend(
[
Expand Down
Loading