Skip to content

Commit 5c28213

Browse files
authored
v4.2.7 Release (#3055)
1 parent c1b0a63 commit 5c28213

File tree

3 files changed

+142
-5
lines changed

3 files changed

+142
-5
lines changed

python/deeplake/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def progress_bar(iterable, *args, **kwargs):
1616
from deeplake.ingestion import from_coco
1717

1818

19-
__version__ = "4.2.3"
19+
__version__ = "4.2.7"
2020

2121
__all__ = [
2222
"__version__",
@@ -51,7 +51,9 @@ def progress_bar(iterable, *args, **kwargs):
5151
"DimensionsMismatchError",
5252
"DtypeMismatch",
5353
"EmbeddingSizeMismatch",
54+
"EmptyColumnNameError",
5455
"Executor",
56+
"ExplainQueryResult",
5557
"ExpiredTokenError",
5658
"FormatNotSupportedError",
5759
"Future",
@@ -142,6 +144,7 @@ def progress_bar(iterable, *args, **kwargs):
142144
"delete",
143145
"disconnect",
144146
"exists",
147+
"explain_query",
145148
"from_coco",
146149
"from_parquet",
147150
"like",

python/deeplake/__init__.pyi

Lines changed: 137 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ __all__ = [
3939
"DimensionsMismatchError",
4040
"DtypeMismatch",
4141
"EmbeddingSizeMismatch",
42+
"EmptyColumnNameError",
4243
"Executor",
44+
"ExplainQueryResult",
4345
"ExpiredTokenError",
4446
"FormatNotSupportedError",
4547
"Future",
@@ -130,6 +132,7 @@ __all__ = [
130132
"delete",
131133
"disconnect",
132134
"exists",
135+
"explain_query",
133136
"from_coco",
134137
"from_parquet",
135138
"like",
@@ -560,6 +563,12 @@ class Metadata(ReadOnlyMetadata):
560563
"""
561564
...
562565

566+
class ExplainQueryResult:
567+
def __str__(self) -> str:
568+
...
569+
def to_dict(self) -> typing.Any:
570+
...
571+
563572
def prepare_query(query: str, token: str | None = None, creds: dict[str, str] | None = None) -> Executor:
564573
"""
565574
Prepares a TQL query for execution with optional authentication.
@@ -786,6 +795,37 @@ def query_async(query: str, token: str | None = None, creds: dict[str, str] | No
786795
"""
787796
...
788797

798+
def explain_query(query: str, token: str | None = None, creds: dict[str, str] | None = None) -> ExplainQueryResult:
799+
"""
800+
Explains TQL query with optional authentication.
801+
802+
Args:
803+
query: TQL query string to explain
804+
token: Optional Activeloop authentication token
805+
creds (dict, optional): Dictionary containing credentials used to access the dataset at the path.
806+
807+
Returns:
808+
ExplainQueryResult: An explain result object to analyze the query.
809+
810+
<!-- test-context
811+
```python
812+
import deeplake
813+
ds = deeplake.create("mem://explain_query")
814+
ds.add_column("category", "text")
815+
ds.append({"category": ["active", "inactive", "not sure"]})
816+
ds.commit()
817+
```
818+
-->
819+
820+
Examples:
821+
Explaining a query:
822+
```python
823+
explain_result = deeplake.explain_query('SELECT * FROM "mem://explain_query" WHERE category == \'active\'')
824+
print(explain_result)
825+
```
826+
"""
827+
...
828+
789829
class Client:
790830
"""
791831
Client for connecting to Activeloop services.
@@ -972,6 +1012,19 @@ class Tag:
9721012
"""
9731013
The name of the tag
9741014
"""
1015+
1016+
@property
1017+
def message(self) -> str:
1018+
"""
1019+
The message of the tag
1020+
"""
1021+
1022+
@property
1023+
def timestamp(self) -> datetime.datetime:
1024+
"""
1025+
The tag creation timestamp
1026+
"""
1027+
...
9751028

9761029
@property
9771030
def version(self) -> str:
@@ -1025,12 +1078,25 @@ class TagView:
10251078
The name of the tag
10261079
"""
10271080

1081+
@property
1082+
def message(self) -> str:
1083+
"""
1084+
The message of the tag
1085+
"""
1086+
10281087
@property
10291088
def version(self) -> str:
10301089
"""
10311090
The version that has been tagged
10321091
"""
10331092

1093+
@property
1094+
def timestamp(self) -> datetime.datetime:
1095+
"""
1096+
The tag creation timestamp
1097+
"""
1098+
...
1099+
10341100
def open(self) -> DatasetView:
10351101
"""
10361102
Fetches the dataset corresponding to the tag
@@ -1095,7 +1161,7 @@ class TagsView:
10951161
"""
10961162
Return a list of tag names
10971163
"""
1098-
...
1164+
...
10991165

11001166
class ColumnDefinition:
11011167
def __str__(self) -> str: ...
@@ -1282,6 +1348,12 @@ class ColumnView:
12821348
"""
12831349
...
12841350

1351+
def get_bytes(self, index: int | slice | list | tuple) -> bytes | list:
1352+
...
1353+
1354+
def get_bytes_async(self, index: int | slice | list | tuple) -> Future:
1355+
...
1356+
12851357
def __len__(self) -> int:
12861358
"""
12871359
Get the number of items in the column.
@@ -1679,6 +1751,12 @@ class Row:
16791751
or await the FutureVoid object in an asynchronous context.
16801752
"""
16811753

1754+
def get_bytes(self, column: str) -> bytes | list:
1755+
...
1756+
1757+
def get_bytes_async(self, column: str) -> Future:
1758+
...
1759+
16821760
def to_dict(self) -> dict:
16831761
"""
16841762
Converts the row to a dictionary.
@@ -1783,6 +1861,12 @@ class RowRange:
17831861
or await the FutureVoid object in an asynchronous context.
17841862
"""
17851863

1864+
def get_bytes(self, column: str) -> bytes | list:
1865+
...
1866+
1867+
def get_bytes_async(self, column: str) -> Future:
1868+
...
1869+
17861870
def summary(self) -> None:
17871871
"""
17881872
Prints a summary of the RowRange.
@@ -1846,6 +1930,12 @@ class RowRangeView:
18461930
or use the Future in an `await` expression.
18471931
"""
18481932

1933+
def get_bytes(self, column: str) -> bytes | list:
1934+
...
1935+
1936+
def get_bytes_async(self, column: str) -> Future:
1937+
...
1938+
18491939
class RowView:
18501940
"""
18511941
Provides access to a particular row in a dataset.
@@ -1889,6 +1979,12 @@ class RowView:
18891979
or use the Future in an `await` expression.
18901980
"""
18911981

1982+
def get_bytes(self, column: str) -> bytes | list:
1983+
...
1984+
1985+
def get_bytes_async(self, column: str) -> Future:
1986+
...
1987+
18921988
def to_dict(self) -> dict:
18931989
"""
18941990
Converts the row to a dictionary.
@@ -1993,6 +2089,33 @@ class DatasetView:
19932089
"""
19942090
...
19952091

2092+
def explain_query(self, query: str) -> ExplainQueryResult:
2093+
"""
2094+
Explains a query.
2095+
2096+
Parameters:
2097+
query: The query to explain
2098+
2099+
Returns:
2100+
ExplainQueryResult: The result of the explanation
2101+
2102+
<!-- test-context
2103+
```python
2104+
import deeplake
2105+
ds = deeplake.create("tmp://")
2106+
ds.add_column("category", "text")
2107+
ds.append({"category": ["active", "inactive", "not sure"]})
2108+
```
2109+
-->
2110+
2111+
Examples:
2112+
```python
2113+
explain_result = ds.explain_query("select * where category == 'inactive'")
2114+
print(explain_result)
2115+
```
2116+
"""
2117+
...
2118+
19962119
def summary(self) -> None:
19972120
"""
19982121
Prints a summary of the dataset.
@@ -2083,7 +2206,7 @@ class DatasetView:
20832206
"""
20842207
...
20852208

2086-
def tag(self, name: str | None = None) -> Tag:
2209+
def tag(self, name: str | None = None, message: str | None = None) -> Tag:
20872210
"""
20882211
Saves the current view as a tag to its source dataset and returns the tag.
20892212
"""
@@ -2285,7 +2408,7 @@ class Dataset(DatasetView):
22852408
"""
22862409
...
22872410

2288-
def tag(self, name: str, version: str | None = None) -> Tag:
2411+
def tag(self, name: str, message: str | None = None, version: str | None = None) -> Tag:
22892412
"""
22902413
Tags a version of the dataset. If no version is given, the current version is tagged.
22912414
@@ -2382,6 +2505,10 @@ class Dataset(DatasetView):
23822505
"""
23832506
...
23842507

2508+
@property
2509+
def _datafiles(self) -> list[tuple[str, int]]:
2510+
...
2511+
23852512
@property
23862513
def id(self) -> str:
23872514
"""
@@ -2880,6 +3007,10 @@ class ReadOnlyDataset(DatasetView):
28803007
"""
28813008
...
28823009

3010+
@property
3011+
def _datafiles(self) -> list[tuple[str, int]]:
3012+
...
3013+
28833014
@property
28843015
def id(self) -> str:
28853016
"""
@@ -3015,6 +3146,9 @@ class IndexAlreadyExistsError(Exception):
30153146
class EmbeddingSizeMismatch(Exception):
30163147
pass
30173148

3149+
class EmptyColumnNameError(Exception):
3150+
pass
3151+
30183152
class InvalidCredsKeyAssignmentError(Exception):
30193153
pass
30203154

python/deeplake/types.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ def Medical(compression: str) -> Type:
10411041
"""
10421042
...
10431043

1044-
def Struct(fields: dict[str, DataType | str]) -> DataType:
1044+
def Struct(fields: dict[str, DataType | str | Type]) -> Type:
10451045
"""
10461046
Defines a custom datatype with specified keys.
10471047

0 commit comments

Comments
 (0)