From 06cab252e9083644428c424032ad3cd3d8106e15 Mon Sep 17 00:00:00 2001 From: kristinagrig06 <70504162+kristinagrig06@users.noreply.github.com> Date: Fri, 26 Mar 2021 12:53:02 +0400 Subject: [PATCH] Fixed issue with resize in mode='a' (#718) * Fixed issue with resize in mode='a' * Add test for resizing dataset in mode 'a' --- hub/api/tests/test_dataset.py | 11 +++++++++++ hub/store/dynamic_tensor.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hub/api/tests/test_dataset.py b/hub/api/tests/test_dataset.py index a2c7ba64cc..16d5e5ea2f 100644 --- a/hub/api/tests/test_dataset.py +++ b/hub/api/tests/test_dataset.py @@ -537,6 +537,16 @@ def test_append_dataset(): assert ds["second"].shape[0] == 120 +def test_append_resize(): + dt = {"first": Tensor(shape=(250, 300)), "second": "float"} + url = "./data/test/append_resize" + ds = Dataset(schema=dt, shape=(100,), url=url, mode="a") + ds.append_shape(20) + assert len(ds) == 120 + ds.resize_shape(150) + assert len(ds) == 150 + + def test_meta_information(): description = {"author": "testing", "description": "here goes the testing text"} @@ -1185,6 +1195,7 @@ def test_minio_endpoint(): test_dataset() test_dataset_batch_write_2() test_append_dataset() + test_append_resize() test_dataset_2() test_text_dataset() test_text_dataset_tokenizer() diff --git a/hub/store/dynamic_tensor.py b/hub/store/dynamic_tensor.py index 466f72be95..e61663b16d 100644 --- a/hub/store/dynamic_tensor.py +++ b/hub/store/dynamic_tensor.py @@ -90,7 +90,7 @@ def __init__( if ("r" in mode or "a" in mode) and exist: meta = json.loads(fs_map.get(".hub.dynamic_tensor").decode("utf-8")) - shape = meta["shape"] + shape = tuple(meta["shape"]) self._dynamic_dims = get_dynamic_dims(shape) self._storage_tensor = zarr.open_array( store=fs_map, mode=mode, synchronizer=synchronizer