Skip to content

Commit

Permalink
Fixed issue with resize in mode='a' (#718)
Browse files Browse the repository at this point in the history
* Fixed issue with resize in mode='a'

* Add test for resizing dataset in mode 'a'
  • Loading branch information
kristinagrig06 committed Mar 26, 2021
1 parent 184c64d commit 06cab25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions hub/api/tests/test_dataset.py
Expand Up @@ -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"}

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion hub/store/dynamic_tensor.py
Expand Up @@ -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
Expand Down

0 comments on commit 06cab25

Please sign in to comment.