From 261f0d77b8632615eddd0e5e5459be307a4b09e6 Mon Sep 17 00:00:00 2001 From: FayazRahman Date: Wed, 6 Sep 2023 22:41:01 +0530 Subject: [PATCH 1/3] init --- conftest.py | 1 + deeplake/api/tests/test_reset.py | 4 +--- deeplake/core/storage/azure.py | 6 ++++++ deeplake/enterprise/convert_to_libdeeplake.py | 2 +- deeplake/enterprise/libdeeplake_query.py | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/conftest.py b/conftest.py index bef2e2d0b2..3cb3db25f3 100644 --- a/conftest.py +++ b/conftest.py @@ -33,6 +33,7 @@ tqdm.monitor_interval = 0 + def pytest_configure(config): config.addinivalue_line( "markers", diff --git a/deeplake/api/tests/test_reset.py b/deeplake/api/tests/test_reset.py index cf6cdaeca3..a02aeb696f 100644 --- a/deeplake/api/tests/test_reset.py +++ b/deeplake/api/tests/test_reset.py @@ -57,9 +57,7 @@ def test_load_corrupt_dataset(path): deeplake.load(path, access_method=access_method) with pytest.raises(ReadOnlyModeError): - deeplake.load( - path, read_only=True, access_method=access_method, reset=True - ) + deeplake.load(path, read_only=True, access_method=access_method, reset=True) ds = deeplake.load( path, diff --git a/deeplake/core/storage/azure.py b/deeplake/core/storage/azure.py index 10ea83887f..00635d9f73 100644 --- a/deeplake/core/storage/azure.py +++ b/deeplake/core/storage/azure.py @@ -142,6 +142,9 @@ def get_bytes( ) if not blob_client.exists(): raise KeyError(path) + # Azure raises an error when trying to download an empty blob + if blob_client.get_blob_properties().size == 0: + return b"" byts = blob_client.download_blob(offset=offset, length=length).readall() return byts @@ -342,6 +345,9 @@ def get_presigned_url(self, path: str, full: bool = False) -> str: def get_object_from_full_url(self, url: str) -> bytes: blob_client, _ = self.get_clients_from_full_path(url) + # Azure raises an error when trying to download an empty blob + if blob_client.get_blob_properties().size == 0: + return b"" return blob_client.download_blob().readall() def _check_update_creds(self, force=False): diff --git a/deeplake/enterprise/convert_to_libdeeplake.py b/deeplake/enterprise/convert_to_libdeeplake.py index c354a27dfa..6fd8845455 100644 --- a/deeplake/enterprise/convert_to_libdeeplake.py +++ b/deeplake/enterprise/convert_to_libdeeplake.py @@ -211,7 +211,7 @@ def dataset_to_libdeeplake(hub2_dataset): commit_id = hub2_dataset.pending_commit_id libdeeplake_dataset.checkout(commit_id) slice_ = hub2_dataset.index.values[0].value - if slice_ != slice(None)and isinstance(slice_, tuple): + if slice_ != slice(None) and isinstance(slice_, tuple): slice_ = list(slice_) libdeeplake_dataset = libdeeplake_dataset[slice_] return libdeeplake_dataset diff --git a/deeplake/enterprise/libdeeplake_query.py b/deeplake/enterprise/libdeeplake_query.py index 76be94205c..29a4669a4d 100644 --- a/deeplake/enterprise/libdeeplake_query.py +++ b/deeplake/enterprise/libdeeplake_query.py @@ -40,7 +40,7 @@ def query(dataset, query_string: str): ds = dataset.libdeeplake_dataset slice_ = dataset.index.values[0].value if slice_ != slice(None) and isinstance(slice_, tuple): - slice_ = list(slice_) + slice_ = list(slice_) ds = ds[slice_] else: ds = dataset_to_libdeeplake(dataset) From 6139dcfa04bbc3c9a16ed31c43593a99be56ccb5 Mon Sep 17 00:00:00 2001 From: FayazRahman Date: Wed, 6 Sep 2023 22:44:54 +0530 Subject: [PATCH 2/3] test --- deeplake/core/storage/tests/test_storage_provider.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deeplake/core/storage/tests/test_storage_provider.py b/deeplake/core/storage/tests/test_storage_provider.py index 4ef827c1b9..1cf57a56c3 100644 --- a/deeplake/core/storage/tests/test_storage_provider.py +++ b/deeplake/core/storage/tests/test_storage_provider.py @@ -220,3 +220,8 @@ def test_azure_storage_clear(azure_storage): azure_storage.clear() assert len(azure_storage) == 0 + + +def test_azure_empty_blob(azure_storage): + azure_storage["empty_blob"] = b"" + assert azure_storage["empty_blob"] == b"" From bbaef5704921e0509ea56571f09e2f0d807fa678 Mon Sep 17 00:00:00 2001 From: FayazRahman Date: Thu, 7 Sep 2023 17:47:34 +0530 Subject: [PATCH 3/3] add coverage --- deeplake/core/storage/tests/test_storage_provider.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deeplake/core/storage/tests/test_storage_provider.py b/deeplake/core/storage/tests/test_storage_provider.py index 1cf57a56c3..b14c325cf1 100644 --- a/deeplake/core/storage/tests/test_storage_provider.py +++ b/deeplake/core/storage/tests/test_storage_provider.py @@ -225,3 +225,7 @@ def test_azure_storage_clear(azure_storage): def test_azure_empty_blob(azure_storage): azure_storage["empty_blob"] = b"" assert azure_storage["empty_blob"] == b"" + assert ( + azure_storage.get_object_from_full_url(f"{azure_storage.root}/empty_blob") + == b"" + )