Skip to content

Commit c359606

Browse files
committed
remove humanize dependency
1 parent cf51de1 commit c359606

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/spyglass/utils/dj_mixin.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import List
66

77
import datajoint as dj
8-
import humanize
98
from datajoint.condition import make_condition
109
from datajoint.errors import DataJointError
1110
from datajoint.expression import QueryExpression
@@ -889,7 +888,14 @@ def get_table_storage_usage(self):
889888
file_paths = [path for path in file_paths if path is not None]
890889
file_sizes = [os.stat(path).st_size for path in file_paths]
891890
total_size = sum(file_sizes)
892-
return humanize.naturalsize(total_size, binary=True), total_size
891+
human_size = total_size
892+
for unit in ["B", "KiB", "MiB", "GiB", "TiB", "PiB"]:
893+
if human_size < 1024.0 or unit == "PiB":
894+
break
895+
human_size /= 1024.0
896+
human_size = f"{human_size:.2f} {unit}"
897+
898+
return human_size, total_size
893899

894900

895901
class SpyglassMixinPart(SpyglassMixin, dj.Part):

0 commit comments

Comments
 (0)