Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
levongh committed Aug 4, 2023
1 parent 8bdbae9 commit a2ddfc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
15 changes: 2 additions & 13 deletions deeplake/core/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ def __getitem__(
enabled_tensors.extend(
self[posixpath.relpath(x, self.group_index)].meta.links.keys()
)

ret = self.__class__(
storage=self.storage,
index=self.index,
Expand Down Expand Up @@ -564,18 +565,6 @@ def __getitem__(
warnings.warn(
"Indexing by integer in a for loop, like `for i in range(len(ds)): ... ds[i]` can be quite slow. Use `for i, sample in enumerate(ds)` instead."
)
if isinstance(item, Index):
indra_item = item.values[0].value
elif isinstance(item, IndexEntry):
indra_item = item.value
else:
indra_item = item

libdeeplake_dataset = (
None
if self.libdeeplake_dataset is None
else self.libdeeplake_dataset[indra_item]
)

ret = self.__class__(
storage=self.storage,
Expand All @@ -591,7 +580,7 @@ def __getitem__(
pad_tensors=self._pad_tensors,
enabled_tensors=self.enabled_tensors,
view_base=self._view_base or self,
libdeeplake_dataset=libdeeplake_dataset,
libdeeplake_dataset=self.libdeeplake_dataset,
)
else:
raise InvalidKeyTypeError(item)
Expand Down
5 changes: 5 additions & 0 deletions deeplake/enterprise/libdeeplake_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def query(dataset, query_string: str):
ds = dataset.indra_ds
elif dataset.libdeeplake_dataset is not None:
ds = dataset.libdeeplake_dataset
slice_ = dataset.index.values[0].value
if slice_ != slice(None):
if isinstance(slice_, tuple):
slice_ = list(slice_)
ds = ds[slice_]
else:
ds = dataset_to_libdeeplake(dataset)
dsv = ds.query(query_string)
Expand Down

0 comments on commit a2ddfc7

Please sign in to comment.