infinity-sdk 0.7.2__tar.gz → 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {infinity_sdk-0.7.2/python/infinity_sdk/infinity_sdk.egg-info → infinity_sdk-0.7.3}/PKG-INFO +2 -2
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/README.md +1 -1
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/pyproject.toml +50 -1
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/README.md +1 -1
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/__init__.py +18 -5
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/common.py +4 -3
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/connection_pool.py +3 -2
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/http_utils.py +1 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/index.py +3 -2
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/infinity.py +0 -1
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/infinity_http.py +44 -34
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/rag_tokenizer.py +8 -8
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/client.py +61 -19
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/db.py +3 -4
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/infinity.py +5 -5
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/query_builder.py +45 -43
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/table.py +36 -25
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/types.py +63 -63
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/utils.py +55 -7
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/table.py +1 -1
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/utils.py +1 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3/python/infinity_sdk/infinity_sdk.egg-info}/PKG-INFO +2 -2
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/LICENSE +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/db.py +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/errors.py +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/huqie.txt +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/huqie.txt.trie +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/__init__.py +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/infinity_thrift_rpc/InfinityService.py +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/infinity_thrift_rpc/__init__.py +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/infinity_thrift_rpc/constants.py +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/infinity_thrift_rpc/ttypes.py +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity_sdk.egg-info/SOURCES.txt +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity_sdk.egg-info/dependency_links.txt +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity_sdk.egg-info/requires.txt +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity_sdk.egg-info/top_level.txt +0 -0
- {infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/setup.cfg +0 -0
{infinity_sdk-0.7.2/python/infinity_sdk/infinity_sdk.egg-info → infinity_sdk-0.7.3}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: infinity-sdk
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: infinity
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Requires-Python: <3.14,>=3.11
|
|
@@ -97,7 +97,7 @@ Infinity supports two working modes, embedded mode and client-server mode. The f
|
|
|
97
97
|
|
|
98
98
|
2. Install the `infinity-sdk` package:
|
|
99
99
|
```bash
|
|
100
|
-
pip install infinity-sdk==0.7.
|
|
100
|
+
pip install infinity-sdk==0.7.3
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
3. Use Infinity to conduct a dense vector search:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "infinity-sdk"
|
|
3
|
-
version = "0.7.
|
|
3
|
+
version = "0.7.3"
|
|
4
4
|
description = "infinity"
|
|
5
5
|
readme = "python/infinity_sdk/README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -71,6 +71,55 @@ filterwarnings = [
|
|
|
71
71
|
'ignore:function ham\(\) is deprecated:DeprecationWarning',
|
|
72
72
|
]
|
|
73
73
|
|
|
74
|
+
[tool.ruff.lint]
|
|
75
|
+
ignore = [
|
|
76
|
+
"RUF059",
|
|
77
|
+
"UP031",
|
|
78
|
+
"LOG015",
|
|
79
|
+
"BLE001",
|
|
80
|
+
"TRY002",
|
|
81
|
+
"B006",
|
|
82
|
+
"B023",
|
|
83
|
+
"S110",
|
|
84
|
+
"RUF012",
|
|
85
|
+
"RUF013",
|
|
86
|
+
"B017",
|
|
87
|
+
"C408",
|
|
88
|
+
"TRY201",
|
|
89
|
+
"SIM103",
|
|
90
|
+
"TRY203",
|
|
91
|
+
"SIM115",
|
|
92
|
+
"SIM118",
|
|
93
|
+
"EXE001",
|
|
94
|
+
"PT014",
|
|
95
|
+
"PLW0602",
|
|
96
|
+
"PERF402",
|
|
97
|
+
"PLR1722",
|
|
98
|
+
"PLW1510",
|
|
99
|
+
"SIM102",
|
|
100
|
+
"UP007",
|
|
101
|
+
"FURB132",
|
|
102
|
+
"SIM113",
|
|
103
|
+
"TRY004",
|
|
104
|
+
"B015",
|
|
105
|
+
"DTZ001",
|
|
106
|
+
"PERF102",
|
|
107
|
+
"PLW0127",
|
|
108
|
+
"SIM101",
|
|
109
|
+
"SIM210",
|
|
110
|
+
"UP022",
|
|
111
|
+
"B008",
|
|
112
|
+
"C417",
|
|
113
|
+
"C418",
|
|
114
|
+
"DTZ005",
|
|
115
|
+
"ISC004",
|
|
116
|
+
"N999",
|
|
117
|
+
"PLR0133",
|
|
118
|
+
"RUF015",
|
|
119
|
+
"SIM117",
|
|
120
|
+
"SIM211",
|
|
121
|
+
]
|
|
122
|
+
|
|
74
123
|
[tool.ruff.lint.per-file-ignores]
|
|
75
124
|
"python/infinity_embedded/local_infinity/client.py" = ["F403", "F405"]
|
|
76
125
|
"python/infinity_embedded/local_infinity/query_builder.py" = ["F403", "F405"]
|
|
@@ -63,7 +63,7 @@ Infinity supports two working modes, embedded mode and client-server mode. The f
|
|
|
63
63
|
|
|
64
64
|
2. Install the `infinity-sdk` package:
|
|
65
65
|
```bash
|
|
66
|
-
pip install infinity-sdk==0.7.
|
|
66
|
+
pip install infinity-sdk==0.7.3
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
3. Use Infinity to conduct a dense vector search:
|
|
@@ -17,17 +17,30 @@
|
|
|
17
17
|
# __version__ = importlib.metadata.version("infinity_sdk")
|
|
18
18
|
|
|
19
19
|
import logging
|
|
20
|
+
|
|
20
21
|
# import pkg_resources
|
|
21
22
|
# __version__ = pkg_resources.get_distribution("infinity_sdk").version
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
from infinity.common import (
|
|
24
|
+
LOCAL_HOST,
|
|
25
|
+
LOCAL_INFINITY_PATH,
|
|
26
|
+
URI,
|
|
27
|
+
InfinityException,
|
|
28
|
+
NetworkAddress,
|
|
29
|
+
)
|
|
30
|
+
from infinity.errors import ErrorCode
|
|
24
31
|
from infinity.infinity import InfinityConnection
|
|
25
32
|
from infinity.remote_thrift.infinity import RemoteThriftInfinityConnection
|
|
26
|
-
from infinity.errors import ErrorCode
|
|
27
33
|
|
|
28
34
|
__all__ = [
|
|
29
|
-
"
|
|
30
|
-
"
|
|
35
|
+
"LOCAL_HOST",
|
|
36
|
+
"LOCAL_INFINITY_PATH",
|
|
37
|
+
"URI",
|
|
38
|
+
"ErrorCode",
|
|
39
|
+
"InfinityConnection",
|
|
40
|
+
"InfinityException",
|
|
41
|
+
"NetworkAddress",
|
|
42
|
+
"RemoteThriftInfinityConnection",
|
|
43
|
+
"connect"
|
|
31
44
|
]
|
|
32
45
|
|
|
33
46
|
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
+
from dataclasses import dataclass, field
|
|
14
15
|
from pathlib import Path
|
|
15
16
|
from typing import Union
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
import numpy as np
|
|
18
19
|
|
|
19
20
|
|
|
@@ -102,13 +103,13 @@ LOCAL_HOST = NetworkAddress("127.0.0.1", 23817)
|
|
|
102
103
|
LOCAL_INFINITY_PATH = "/var/infinity"
|
|
103
104
|
|
|
104
105
|
|
|
105
|
-
class ConflictType
|
|
106
|
+
class ConflictType:
|
|
106
107
|
Ignore = 0
|
|
107
108
|
Error = 1
|
|
108
109
|
Replace = 2
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
class SortType
|
|
112
|
+
class SortType:
|
|
112
113
|
Asc = 0
|
|
113
114
|
Desc = 1
|
|
114
115
|
|
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import logging
|
|
15
16
|
from threading import Lock
|
|
17
|
+
|
|
16
18
|
import infinity
|
|
17
19
|
from infinity.common import NetworkAddress
|
|
18
|
-
import logging
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
class ConnectionPool
|
|
22
|
+
class ConnectionPool:
|
|
22
23
|
def __init__(self, uri=NetworkAddress("127.0.0.1", 23817), max_size=16):
|
|
23
24
|
self.uri_ = uri
|
|
24
25
|
self.max_size_ = max_size
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
from enum import Enum
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
from sqlglot import maybe_parse
|
|
18
|
+
|
|
18
19
|
from infinity.common import InfinityException
|
|
19
20
|
from infinity.errors import ErrorCode
|
|
21
|
+
from infinity.remote_thrift.infinity_thrift_rpc import ttypes
|
|
20
22
|
from infinity.remote_thrift.utils import parse_expr
|
|
21
|
-
from sqlglot import maybe_parse
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
class IndexType(Enum):
|
|
@@ -1,28 +1,45 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
import logging
|
|
1
3
|
import re
|
|
2
4
|
import time
|
|
5
|
+
from collections import namedtuple
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import Any
|
|
3
8
|
|
|
4
|
-
import requests
|
|
5
|
-
import logging
|
|
6
|
-
import ast
|
|
7
|
-
from numpy import dtype
|
|
8
|
-
from .http_utils import (
|
|
9
|
-
baseHeader, baseResponse, baseData, default_url, baseCreateOptions, baseDropOptions,
|
|
10
|
-
index_type_transfrom, ExplainType_transfrom, is_list, is_date, is_time, is_datetime,
|
|
11
|
-
is_sparse, str2sparse, type_to_dtype, function_return_type, is_float, functions, bool_functions
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
from infinity.common import ConflictType, InfinityException, SparseVector, SortType, FDE
|
|
15
|
-
from typing import Optional, Any
|
|
16
|
-
from infinity.errors import ErrorCode
|
|
17
|
-
from infinity.utils import deprecated_api
|
|
18
9
|
import numpy as np
|
|
19
10
|
import pandas as pd
|
|
20
11
|
import polars as pl
|
|
21
12
|
import pyarrow as pa
|
|
13
|
+
import requests
|
|
14
|
+
from numpy import dtype
|
|
15
|
+
|
|
16
|
+
from infinity.common import FDE, ConflictType, InfinityException, SortType, SparseVector
|
|
17
|
+
from infinity.errors import ErrorCode
|
|
22
18
|
from infinity.table import ExplainType
|
|
23
|
-
from
|
|
24
|
-
|
|
25
|
-
from
|
|
19
|
+
from infinity.utils import deprecated_api
|
|
20
|
+
|
|
21
|
+
from .http_utils import (
|
|
22
|
+
ExplainType_transfrom,
|
|
23
|
+
baseCreateOptions,
|
|
24
|
+
baseData,
|
|
25
|
+
baseDropOptions,
|
|
26
|
+
baseHeader,
|
|
27
|
+
baseResponse,
|
|
28
|
+
bool_functions,
|
|
29
|
+
default_url,
|
|
30
|
+
function_return_type,
|
|
31
|
+
functions,
|
|
32
|
+
index_type_transfrom,
|
|
33
|
+
is_date,
|
|
34
|
+
is_datetime,
|
|
35
|
+
is_float,
|
|
36
|
+
is_list,
|
|
37
|
+
is_sparse,
|
|
38
|
+
is_time,
|
|
39
|
+
str2sparse,
|
|
40
|
+
type_to_dtype,
|
|
41
|
+
)
|
|
42
|
+
|
|
26
43
|
|
|
27
44
|
def is_json_function(col_name: str) -> bool:
|
|
28
45
|
"""Check if column name is a JSON extraction function"""
|
|
@@ -40,7 +57,7 @@ def is_json_function(col_name: str) -> bool:
|
|
|
40
57
|
return any(col_name_lower.startswith(func) for func in json_functions)
|
|
41
58
|
|
|
42
59
|
|
|
43
|
-
def _parse_cast_target_type(cast_expr: str) ->
|
|
60
|
+
def _parse_cast_target_type(cast_expr: str) -> str | None:
|
|
44
61
|
if not cast_expr.lower().startswith("cast("):
|
|
45
62
|
return None
|
|
46
63
|
|
|
@@ -180,7 +197,6 @@ class http_network_util:
|
|
|
180
197
|
pass
|
|
181
198
|
|
|
182
199
|
logging.debug("----------------------------------------------")
|
|
183
|
-
return
|
|
184
200
|
|
|
185
201
|
def get_database_result(self, resp, expect={}):
|
|
186
202
|
try:
|
|
@@ -1044,7 +1060,7 @@ class table_http_result:
|
|
|
1044
1060
|
self._highlight = highlight
|
|
1045
1061
|
return self
|
|
1046
1062
|
|
|
1047
|
-
def sort(self, order_by_expr_list:
|
|
1063
|
+
def sort(self, order_by_expr_list: list[list[str, SortType]] | None):
|
|
1048
1064
|
for order_by_expr in order_by_expr_list:
|
|
1049
1065
|
tmp = {}
|
|
1050
1066
|
if len(order_by_expr) != 2:
|
|
@@ -1084,7 +1100,7 @@ class table_http_result:
|
|
|
1084
1100
|
self._option = option
|
|
1085
1101
|
return self
|
|
1086
1102
|
|
|
1087
|
-
def match_text(self, fields: str, query: str, topn: int, opt_params:
|
|
1103
|
+
def match_text(self, fields: str, query: str, topn: int, opt_params: dict | None = None):
|
|
1088
1104
|
tmp_match_expr = {"match_method": "text", "fields": fields, "matching_text": query, "topn": topn}
|
|
1089
1105
|
if opt_params is not None:
|
|
1090
1106
|
tmp_match_expr["params"] = opt_params
|
|
@@ -1096,7 +1112,7 @@ class table_http_result:
|
|
|
1096
1112
|
return self.match_text(*args, **kwargs)
|
|
1097
1113
|
|
|
1098
1114
|
def match_tensor(self, column_name: str, query_data, query_data_type: str, topn: int,
|
|
1099
|
-
extra_option:
|
|
1115
|
+
extra_option: dict | None = None):
|
|
1100
1116
|
tmp_match_tensor = {"match_method": "tensor", "field": column_name, "query_tensor": query_data,
|
|
1101
1117
|
"element_type": query_data_type, "topn": topn}
|
|
1102
1118
|
if extra_option is not None:
|
|
@@ -1105,7 +1121,7 @@ class table_http_result:
|
|
|
1105
1121
|
return self
|
|
1106
1122
|
|
|
1107
1123
|
def match_sparse(self, vector_column_name: str, sparse_data: SparseVector | dict, distance_type: str, topn: int,
|
|
1108
|
-
opt_params:
|
|
1124
|
+
opt_params: dict | None = None):
|
|
1109
1125
|
tmp_match_sparse = {"match_method": "sparse", "fields": vector_column_name,
|
|
1110
1126
|
"query_vector": sparse_data.to_dict(), "metric_type": distance_type, "topn": topn}
|
|
1111
1127
|
if opt_params is not None:
|
|
@@ -1118,7 +1134,7 @@ class table_http_result:
|
|
|
1118
1134
|
return self
|
|
1119
1135
|
|
|
1120
1136
|
def match_dense(self, fields: str, query_vector: list, element_type: str, metric_type: str, top_k: int,
|
|
1121
|
-
opt_params:
|
|
1137
|
+
opt_params: dict | None = None):
|
|
1122
1138
|
tmp_match_dense = {"match_method": "dense", "fields": fields, "query_vector": query_vector,
|
|
1123
1139
|
"element_type": element_type, "metric_type": metric_type, "topn": top_k}
|
|
1124
1140
|
if opt_params is not None:
|
|
@@ -1130,7 +1146,7 @@ class table_http_result:
|
|
|
1130
1146
|
deprecated_api("knn is deprecated, please use match_dense instead")
|
|
1131
1147
|
return self.match_dense(*args, **kwargs)
|
|
1132
1148
|
|
|
1133
|
-
def fusion(self, method: str, topn: int, fusion_params:
|
|
1149
|
+
def fusion(self, method: str, topn: int, fusion_params: dict | None = None):
|
|
1134
1150
|
tmp_fusion_expr = {"fusion_method": method, "topn": topn}
|
|
1135
1151
|
if method == "match_tensor":
|
|
1136
1152
|
tmp_new_params = {"field": fusion_params["field"], "query_tensor": fusion_params["query_tensor"],
|
|
@@ -1184,18 +1200,12 @@ class table_http_result:
|
|
|
1184
1200
|
if len(tup) == line_i + 1:
|
|
1185
1201
|
continue
|
|
1186
1202
|
|
|
1187
|
-
if v is None:
|
|
1188
|
-
new_tup = tup + (v,)
|
|
1189
|
-
elif isinstance(v, (int, float)):
|
|
1203
|
+
if v is None or isinstance(v, (int, float)):
|
|
1190
1204
|
new_tup = tup + (v,)
|
|
1191
1205
|
elif is_list(v) and not is_json_function(col_name):
|
|
1192
1206
|
# Don't parse lists for JSON extraction functions - keep them as strings
|
|
1193
1207
|
new_tup = tup + (ast.literal_eval(v),)
|
|
1194
|
-
elif is_date(v):
|
|
1195
|
-
new_tup = tup + (v,)
|
|
1196
|
-
elif is_time(v):
|
|
1197
|
-
new_tup = tup + (v,)
|
|
1198
|
-
elif is_datetime(v):
|
|
1208
|
+
elif is_date(v) or is_time(v) or is_datetime(v):
|
|
1199
1209
|
new_tup = tup + (v,)
|
|
1200
1210
|
elif is_sparse(v): # sparse vector
|
|
1201
1211
|
sparse_vec = str2sparse(v)
|
|
@@ -1312,7 +1322,7 @@ class table_http_result:
|
|
|
1312
1322
|
|
|
1313
1323
|
|
|
1314
1324
|
@dataclass
|
|
1315
|
-
class database_result
|
|
1325
|
+
class database_result:
|
|
1316
1326
|
def __init__(self, list=[], database_name: str = "", error_code=ErrorCode.OK, columns=[], index_names=[],
|
|
1317
1327
|
node_name="", node_role="", node_status="", index_type=None, index_comment=None, deleted_rows=0,
|
|
1318
1328
|
data={}, nodes=[], error_msg="", snapshots=[], config_value: Any = None):
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
# ]
|
|
26
26
|
# ///
|
|
27
27
|
|
|
28
|
-
import logging
|
|
29
28
|
# logging.basicConfig(
|
|
30
29
|
# level=logging.INFO,
|
|
31
30
|
# format='%(asctime)s - %(levelname)s - %(message)s',
|
|
@@ -33,16 +32,17 @@ import logging
|
|
|
33
32
|
# )
|
|
34
33
|
import argparse
|
|
35
34
|
import copy
|
|
36
|
-
import
|
|
35
|
+
import logging
|
|
37
36
|
import math
|
|
38
37
|
import os
|
|
39
38
|
import re
|
|
40
39
|
import string
|
|
40
|
+
|
|
41
|
+
import datrie
|
|
41
42
|
from hanziconv import HanziConv
|
|
42
43
|
from nltk import word_tokenize
|
|
43
44
|
from nltk.stem import SnowballStemmer, WordNetLemmatizer
|
|
44
45
|
|
|
45
|
-
|
|
46
46
|
# Map language names (lowercase) to NLTK SnowballStemmer language names.
|
|
47
47
|
# Used by set_language() to configure language-specific stemming.
|
|
48
48
|
_SNOWBALL_LANGUAGE_MAP = {
|
|
@@ -307,7 +307,7 @@ class RagTokenizer:
|
|
|
307
307
|
tks.append(tk)
|
|
308
308
|
# F /= len(tks)
|
|
309
309
|
L /= len(tks)
|
|
310
|
-
logging.debug("[SC] {} {} {} {} {
|
|
310
|
+
logging.debug(f"[SC] {tks} {len(tks)} {L} {F} {B / len(tks) + L + F}")
|
|
311
311
|
return tks, B / len(tks) + L + F
|
|
312
312
|
|
|
313
313
|
def _sort_tokens(self, tkslist):
|
|
@@ -439,8 +439,8 @@ class RagTokenizer:
|
|
|
439
439
|
tks, s = self._max_forward(L)
|
|
440
440
|
tks1, s1 = self._max_backward(L)
|
|
441
441
|
if self.DEBUG:
|
|
442
|
-
logging.debug("[FW] {} {}"
|
|
443
|
-
logging.debug("[BW] {} {}"
|
|
442
|
+
logging.debug(f"[FW] {tks} {s}")
|
|
443
|
+
logging.debug(f"[BW] {tks1} {s1}")
|
|
444
444
|
|
|
445
445
|
i, j, _i, _j = 0, 0, 0, 0
|
|
446
446
|
same = 0
|
|
@@ -488,7 +488,7 @@ class RagTokenizer:
|
|
|
488
488
|
res.append(" ".join(self._sort_tokens(tkslist)[0][0]))
|
|
489
489
|
|
|
490
490
|
res = " ".join(res)
|
|
491
|
-
logging.debug("[TKS] {
|
|
491
|
+
logging.debug(f"[TKS] {self.merge_(res)}")
|
|
492
492
|
return self.merge_(res)
|
|
493
493
|
|
|
494
494
|
def fine_grained_tokenize(self, tks: str) -> str:
|
|
@@ -626,7 +626,7 @@ if __name__ == '__main__':
|
|
|
626
626
|
results.append(result)
|
|
627
627
|
|
|
628
628
|
except Exception as e:
|
|
629
|
-
error_msg = f"ERROR: {
|
|
629
|
+
error_msg = f"ERROR: {e!s}"
|
|
630
630
|
logging.error(f"Failed to process text: {text} - {e}")
|
|
631
631
|
results.append(error_msg)
|
|
632
632
|
|
{infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/client.py
RENAMED
|
@@ -14,31 +14,72 @@
|
|
|
14
14
|
|
|
15
15
|
import logging
|
|
16
16
|
from functools import wraps
|
|
17
|
-
from readerwriterlock import rwlock
|
|
18
17
|
|
|
18
|
+
from readerwriterlock import rwlock
|
|
19
19
|
from thrift.protocol import TBinaryProtocol
|
|
20
20
|
from thrift.transport import TSocket, TTransport
|
|
21
21
|
from thrift.transport.TTransport import TTransportException
|
|
22
22
|
|
|
23
23
|
from infinity import URI
|
|
24
|
-
from infinity.
|
|
24
|
+
from infinity.common import InfinityException
|
|
25
|
+
from infinity.errors import ErrorCode
|
|
26
|
+
from infinity.remote_thrift.infinity_thrift_rpc import InfinityService, ttypes
|
|
25
27
|
from infinity.remote_thrift.infinity_thrift_rpc.ttypes import (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
CreateSystemSnapshotRequest, RestoreSnapshotRequest, ListSnapshotsRequest, ShowSnapshotRequest,
|
|
31
|
-
DropSnapshotRequest, ConfigValue, SetConfigRequest, ShowConfigRequest,
|
|
28
|
+
AddColumnsRequest,
|
|
29
|
+
AlterIndexRequest,
|
|
30
|
+
CommonRequest,
|
|
31
|
+
CommonResponse,
|
|
32
32
|
CompactRequest,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
ConfigValue,
|
|
34
|
+
ConnectRequest,
|
|
35
|
+
CreateConflict,
|
|
36
|
+
CreateDatabaseRequest,
|
|
37
|
+
CreateDatabaseSnapshotRequest,
|
|
38
|
+
CreateIndexRequest,
|
|
39
|
+
CreateOption,
|
|
40
|
+
CreateSystemSnapshotRequest,
|
|
41
|
+
CreateTableRequest,
|
|
42
|
+
CreateTableSnapshotRequest,
|
|
43
|
+
DeleteRequest,
|
|
44
|
+
DropColumnsRequest,
|
|
45
|
+
DropConflict,
|
|
46
|
+
DropDatabaseRequest,
|
|
47
|
+
DropIndexRequest,
|
|
48
|
+
DropOption,
|
|
49
|
+
DropSnapshotRequest,
|
|
50
|
+
DropTableRequest,
|
|
51
|
+
DumpIndexRequest,
|
|
52
|
+
ExplainRequest,
|
|
53
|
+
ExportRequest,
|
|
54
|
+
Field,
|
|
55
|
+
GetDatabaseRequest,
|
|
56
|
+
GetTableRequest,
|
|
57
|
+
ImportRequest,
|
|
58
|
+
IndexInfo,
|
|
59
|
+
InsertRequest,
|
|
60
|
+
ListDatabaseRequest,
|
|
61
|
+
ListIndexRequest,
|
|
62
|
+
ListSnapshotsRequest,
|
|
63
|
+
ListTableRequest,
|
|
64
|
+
OptimizeRequest,
|
|
65
|
+
RenameTableRequest,
|
|
66
|
+
RestoreSnapshotRequest,
|
|
67
|
+
SelectRequest,
|
|
68
|
+
SetConfigRequest,
|
|
69
|
+
ShowBlockColumnRequest,
|
|
70
|
+
ShowBlockRequest,
|
|
71
|
+
ShowBlocksRequest,
|
|
72
|
+
ShowColumnsRequest,
|
|
73
|
+
ShowConfigRequest,
|
|
74
|
+
ShowCurrentNodeRequest,
|
|
75
|
+
ShowDatabaseRequest,
|
|
76
|
+
ShowIndexRequest,
|
|
77
|
+
ShowSegmentRequest,
|
|
78
|
+
ShowSegmentsRequest,
|
|
79
|
+
ShowSnapshotRequest,
|
|
80
|
+
ShowTableRequest,
|
|
81
|
+
UpdateRequest,
|
|
38
82
|
)
|
|
39
|
-
import infinity.remote_thrift.infinity_thrift_rpc.ttypes as ttypes
|
|
40
|
-
from infinity.errors import ErrorCode
|
|
41
|
-
from infinity.common import InfinityException
|
|
42
83
|
|
|
43
84
|
TRY_TIMES = 10
|
|
44
85
|
|
|
@@ -123,8 +164,9 @@ class ThriftInfinityClient:
|
|
|
123
164
|
# version: 0.6.8 and 0.6.9 and 0.6.10, client_version: 33
|
|
124
165
|
# version: 0.6.13, client_version: 34
|
|
125
166
|
# version: 0.6.15, client_version: 35
|
|
126
|
-
# version: 0.7.0, 0.7.1, 0.7.2 client_version: 36
|
|
127
|
-
|
|
167
|
+
# version: 0.7.0, 0.7.1, 0.7.2, client_version: 36
|
|
168
|
+
# version: 0.7.3, client_version: 37
|
|
169
|
+
res = self.client.Connect(ConnectRequest(client_version=37)) # 0.7.3
|
|
128
170
|
if res.error_code != 0:
|
|
129
171
|
raise InfinityException(res.error_code, res.error_msg)
|
|
130
172
|
self.session_id = res.session_id
|
|
@@ -144,7 +186,7 @@ class ThriftInfinityClient:
|
|
|
144
186
|
self._reconnect()
|
|
145
187
|
self.session_i += 1
|
|
146
188
|
self.logger.debug(
|
|
147
|
-
f"Tried {i} times, session_id: {self.session_id}, session_i: {self.session_i}, exception: {
|
|
189
|
+
f"Tried {i} times, session_id: {self.session_id}, session_i: {self.session_i}, exception: {e!s}")
|
|
148
190
|
except Exception:
|
|
149
191
|
raise
|
|
150
192
|
else:
|
|
@@ -14,17 +14,16 @@
|
|
|
14
14
|
|
|
15
15
|
from abc import ABC
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
from infinity.common import ConflictType, InfinityException
|
|
18
18
|
from infinity.db import Database
|
|
19
19
|
from infinity.errors import ErrorCode
|
|
20
|
+
from infinity.remote_thrift.infinity_thrift_rpc import ttypes
|
|
20
21
|
from infinity.remote_thrift.table import RemoteTable
|
|
21
22
|
from infinity.remote_thrift.utils import (
|
|
22
23
|
check_valid_name,
|
|
23
|
-
name_validity_check,
|
|
24
24
|
get_ordinary_info,
|
|
25
|
+
name_validity_check,
|
|
25
26
|
)
|
|
26
|
-
from infinity.common import ConflictType
|
|
27
|
-
from infinity.common import InfinityException
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
class RemoteDatabase(Database, ABC):
|
{infinity_sdk-0.7.2 → infinity_sdk-0.7.3}/python/infinity_sdk/infinity/remote_thrift/infinity.py
RENAMED
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from abc import ABC
|
|
16
15
|
import logging
|
|
16
|
+
from abc import ABC
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
from typing import Any
|
|
17
19
|
|
|
18
|
-
import infinity.remote_thrift.infinity_thrift_rpc.ttypes as ttypes
|
|
19
20
|
from infinity import InfinityConnection
|
|
21
|
+
from infinity.common import ConflictType, InfinityException
|
|
20
22
|
from infinity.errors import ErrorCode
|
|
21
23
|
from infinity.remote_thrift.client import ThriftInfinityClient
|
|
22
24
|
from infinity.remote_thrift.db import RemoteDatabase
|
|
25
|
+
from infinity.remote_thrift.infinity_thrift_rpc import ttypes
|
|
23
26
|
from infinity.remote_thrift.utils import name_validity_check
|
|
24
|
-
from infinity.common import ConflictType, InfinityException
|
|
25
|
-
from typing import Any
|
|
26
|
-
from dataclasses import dataclass
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
@dataclass
|