Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow virtual tensors .data to use indra_ts.numpy as fallback. #2873

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions deeplake/core/dataset/indra_tensor_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,33 @@ def numpy(

def text(self, fetch_chunks: bool = False):
"""Return text data. Only applicable for tensors with 'text' base htype."""
bs = self.indra_tensor.bytes()
if self.ndim == 1:
return bs.decode()
if isinstance(bs, bytes):
return [bs.decode()]
return list(b.decode() for b in bs)
try:
bs = self.indra_tensor.bytes()
if self.ndim == 1:
return bs.decode()
if isinstance(bs, bytes):
return [bs.decode()]
return list(b.decode() for b in bs)
except Exception as e:
bs = self.indra_tensor.numpy(aslist=True)
if self.ndim == 1:
return bs[0]
return list(b[0] for b in bs)

def dict(self, fetch_chunks: bool = False):
"""Return json data. Only applicable for tensors with 'json' base htype."""
bs = self.indra_tensor.bytes()
if self.ndim == 1:
return json.loads(bs.decode())
if isinstance(bs, bytes):
return [json.loads(bs.decode())]
return list(json.loads(b.decode()) for b in self.indra_tensor.bytes())
try:
bs = self.indra_tensor.bytes()
if self.ndim == 1:
return json.loads(bs.decode())
if isinstance(bs, bytes):
return [json.loads(bs.decode())]
return list(json.loads(b.decode()) for b in self.indra_tensor.bytes())
except Exception as e:
bs = self.indra_tensor.numpy(aslist=True)
if self.ndim == 1:
return bs[0]
return list(b[0] for b in bs)

@property
def dtype(self):
Expand Down
2 changes: 1 addition & 1 deletion deeplake/util/bugout_token.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUGOUT_TOKEN = "f7176d62-73fa-4ecc-b24d-624364bddcb0"
BUGOUT_TOKEN = "0095ccd3-7ff0-41b9-b031-f4eb58f00906"
Loading