Skip to content

Commit

Permalink
Merge pull request #2846 from activeloopai/decode_method_data
Browse files Browse the repository at this point in the history
added handling of object dtype in decode method data
  • Loading branch information
activesoull committed May 8, 2024
2 parents aa5dc93 + 155e040 commit a398a6f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deeplake/core/storage/gcs.py
Expand Up @@ -528,5 +528,7 @@ def get_object_from_full_url(self, url: str):

def get_creds(self):
d = self.scoped_credentials.get_token_info()
d["expiration"] = self.expiration or ""
d["expiration"] = (
self.expiration if hasattr(self, "expiration") and self.expiration else ""
)
return d
24 changes: 24 additions & 0 deletions deeplake/enterprise/dataloader.py
Expand Up @@ -801,6 +801,27 @@ def __get_indra_dataloader(
info=info,
)

def _fill_sample_info_tensors(
self,
dataset,
sample_info_tensors,
json_tensors,
list_tensors,
):
for tensor_name in sample_info_tensors:
tensor = dataset._get_tensor_from_root(tensor_name)
if len(tensor) == 0:
raise EmptyTensorError(
f" the dataset has an empty tensor {tensor_name}, pytorch dataloader can't be created."
f" Please either populate the tensor or pass tensors argument to .pytorch that excludes this"
f" tensor."
)
meta = tensor.meta
if meta.htype == "json":
json_tensors.append(tensor_name)
elif meta.htype in ["list", "tag"]:
list_tensors.append(tensor_name)

def __iter__(self):
if self._dataloader is None:
dataset = self.dataset
Expand All @@ -825,6 +846,9 @@ def __iter__(self):
sample_info_tensors, tensor_info_tensors = find_additional_tensors_and_info(
dataset, data_tensors
)
self._fill_sample_info_tensors(
dataset, sample_info_tensors, json_tensors, list_tensors
)
tensors.extend(sample_info_tensors)
htype_dict, ndim_dict, tensor_info_dict = get_htype_ndim_tensor_info_dicts(
dataset, data_tensors, tensor_info_tensors
Expand Down

0 comments on commit a398a6f

Please sign in to comment.