Skip to content

Commit 06cab25

Browse files
Fixed issue with resize in mode='a' (#718)
* Fixed issue with resize in mode='a' * Add test for resizing dataset in mode 'a'
1 parent 184c64d commit 06cab25

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

hub/api/tests/test_dataset.py

+11
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,16 @@ def test_append_dataset():
537537
assert ds["second"].shape[0] == 120
538538

539539

540+
def test_append_resize():
541+
dt = {"first": Tensor(shape=(250, 300)), "second": "float"}
542+
url = "./data/test/append_resize"
543+
ds = Dataset(schema=dt, shape=(100,), url=url, mode="a")
544+
ds.append_shape(20)
545+
assert len(ds) == 120
546+
ds.resize_shape(150)
547+
assert len(ds) == 150
548+
549+
540550
def test_meta_information():
541551
description = {"author": "testing", "description": "here goes the testing text"}
542552

@@ -1185,6 +1195,7 @@ def test_minio_endpoint():
11851195
test_dataset()
11861196
test_dataset_batch_write_2()
11871197
test_append_dataset()
1198+
test_append_resize()
11881199
test_dataset_2()
11891200
test_text_dataset()
11901201
test_text_dataset_tokenizer()

hub/store/dynamic_tensor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(
9090

9191
if ("r" in mode or "a" in mode) and exist:
9292
meta = json.loads(fs_map.get(".hub.dynamic_tensor").decode("utf-8"))
93-
shape = meta["shape"]
93+
shape = tuple(meta["shape"])
9494
self._dynamic_dims = get_dynamic_dims(shape)
9595
self._storage_tensor = zarr.open_array(
9696
store=fs_map, mode=mode, synchronizer=synchronizer

0 commit comments

Comments
 (0)