Skip to content

Commit 0de0bf1

Browse files
committed
update
1 parent f7d265a commit 0de0bf1

24 files changed

+178
-196
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,31 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
17+
image_tag: ["4.4.1.0-100000032025101610"]
18+
init_sql: ["ALTER SYSTEM ob_vector_memory_limit_percentage = 30; SET GLOBAL ob_query_timeout=100000000;"]
19+
test_filter: ["tests/test_hybrid_search.py::HybridSearchTest"]
1620
include:
17-
- image_tag: "4.3.5.3-103000092025080818"
21+
- python-version: 3.12
22+
image_tag: "4.3.5.3-103000092025080818"
1823
init_sql: "ALTER SYSTEM ob_vector_memory_limit_percentage = 30; CREATE USER 'jtuser'@'%'; GRANT SELECT, INSERT, UPDATE, DELETE ON test.* TO 'jtuser'@'%'; FLUSH PRIVILEGES;"
1924
test_filter: "-k \"not HybridSearchTest\""
20-
- image_tag: "4.4.1.0-100000032025101610"
21-
init_sql: "ALTER SYSTEM ob_vector_memory_limit_percentage = 30; SET GLOBAL ob_query_timeout=100000000;"
22-
test_filter: "tests/test_hybrid_search.py::HybridSearchTest"
2325

2426
steps:
27+
- name: Check out code
28+
uses: actions/checkout@v4
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v6
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Install dependencies
36+
run: uv sync --dev
37+
38+
- name: Package build test
39+
run: uv build
40+
2541
- name: Free disk space
2642
uses: kfir4444/free-disk-space@main
2743
with:
@@ -32,21 +48,6 @@ jobs:
3248
large-packages: true
3349
swap-storage: true
3450

35-
- name: Check out code
36-
uses: actions/checkout@v4
37-
38-
- name: Set up Python
39-
uses: actions/setup-python@v3
40-
with:
41-
python-version: '3.x'
42-
43-
- name: Install uv
44-
uses: astral-sh/setup-uv@v6
45-
46-
- name: Install dependencies
47-
run: |
48-
uv sync --dev
49-
5051
- name: Start OceanBase container
5152
uses: oceanbase/setup-oceanbase-ce@v1
5253
with:

pyobvector/client/collection_schema.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""FieldSchema & CollectionSchema definition module to be compatible with Milvus."""
22
import copy
3-
from typing import Optional, List
43
from sqlalchemy import Column
54
from .schema_type import DataType, convert_datatype_to_sqltype
65
from .exceptions import *
@@ -125,8 +124,8 @@ class CollectionSchema:
125124
"""
126125
def __init__(
127126
self,
128-
fields: Optional[List[FieldSchema]] = None,
129-
partitions: Optional[ObPartition] = None,
127+
fields: list[FieldSchema] | None = None,
128+
partitions: ObPartition | None = None,
130129
description: str = "", # ignored in oceanbase
131130
**kwargs,
132131
):

pyobvector/client/fts_index_param.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""A module to specify fts index parameters"""
22
from enum import Enum
3-
from typing import List, Optional
43

54
class FtsParser(Enum):
65
IK = 0
@@ -11,8 +10,8 @@ class FtsIndexParam:
1110
def __init__(
1211
self,
1312
index_name: str,
14-
field_names: List[str],
15-
parser_type: Optional[FtsParser],
13+
field_names: list[str],
14+
parser_type: FtsParser | None,
1615
):
1716
self.index_name = index_name
1817
self.field_names = field_names

pyobvector/client/hybrid_search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""OceanBase Hybrid Search Client."""
22
import json
33
import logging
4-
from typing import Dict, Any
4+
from typing import Any
55

66
from sqlalchemy import text
77

@@ -41,7 +41,7 @@ def __init__(
4141
def search(
4242
self,
4343
index: str,
44-
body: Dict[str, Any],
44+
body: dict[str, Any],
4545
**kwargs,
4646
):
4747
"""Execute hybrid search with parameter compatible with Elasticsearch.
@@ -66,7 +66,7 @@ def search(
6666
def get_sql(
6767
self,
6868
index: str,
69-
body: Dict[str, Any],
69+
body: dict[str, Any],
7070
) -> str:
7171
"""Get the SQL actually to be executed in hybrid search.
7272

pyobvector/client/index_param.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""A module to specify vector index parameters for MilvusLikeClient"""
22
from enum import Enum
3-
from typing import Union
43

54
class VecIndexType(Enum):
65
"""Vector index algorithm type"""
@@ -34,7 +33,7 @@ class IndexParam:
3433
DAAT_ALGO_NAME = "daat"
3534

3635
def __init__(
37-
self, index_name: str, field_name: str, index_type: Union[VecIndexType, str], **kwargs
36+
self, index_name: str, field_name: str, index_type: VecIndexType | str, **kwargs
3837
):
3938
self.index_name = index_name
4039
self.field_name = field_name

pyobvector/client/milvus_like_client.py

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Milvus Like Client."""
22
import logging
33
import json
4-
from typing import Optional, Union, Dict, List
54

65
from sqlalchemy.exc import NoSuchTableError
76
from sqlalchemy import (
@@ -51,15 +50,15 @@ def create_schema(self, **kwargs) -> CollectionSchema:
5150
def create_collection(
5251
self,
5352
collection_name: str,
54-
dimension: Optional[int] = None,
53+
dimension: int | None = None,
5554
primary_field_name: str = "id",
56-
id_type: Union[DataType, str] = DataType.INT64,
55+
id_type: DataType | str = DataType.INT64,
5756
vector_field_name: str = "vector",
5857
metric_type: str = "l2",
5958
auto_id: bool = False,
60-
timeout: Optional[float] = None,
61-
schema: Optional[CollectionSchema] = None, # Used for custom setup
62-
index_params: Optional[IndexParams] = None, # Used for custom setup
59+
timeout: float | None = None,
60+
schema: CollectionSchema | None = None, # Used for custom setup
61+
index_params: IndexParams | None = None, # Used for custom setup
6362
max_length: int = 16384,
6463
**kwargs,
6564
): # pylint: disable=unused-argument
@@ -146,8 +145,8 @@ def create_collection(
146145
)
147146

148147
def get_collection_stats(
149-
self, collection_name: str, timeout: Optional[float] = None # pylint: disable=unused-argument
150-
) -> Dict:
148+
self, collection_name: str, timeout: float | None = None # pylint: disable=unused-argument
149+
) -> dict:
151150
"""Get collection row count.
152151
153152
Args:
@@ -166,7 +165,7 @@ def get_collection_stats(
166165
return {"row_count": cnt}
167166

168167
def has_collection(
169-
self, collection_name: str, timeout: Optional[float] = None # pylint: disable=unused-argument
168+
self, collection_name: str, timeout: float | None = None # pylint: disable=unused-argument
170169
) -> bool: # pylint: disable=unused-argument
171170
"""Check if collection exists.
172171
@@ -188,7 +187,7 @@ def drop_collection(self, collection_name: str) -> None:
188187
self.drop_table_if_exist(collection_name)
189188

190189
def rename_collection(
191-
self, old_name: str, new_name: str, timeout: Optional[float] = None # pylint: disable=unused-argument
190+
self, old_name: str, new_name: str, timeout: float | None = None # pylint: disable=unused-argument
192191
) -> None:
193192
"""Rename collection.
194193
@@ -228,7 +227,7 @@ def create_index(
228227
self,
229228
collection_name: str,
230229
index_params: IndexParams,
231-
timeout: Optional[float] = None,
230+
timeout: float | None = None,
232231
**kwargs,
233232
): # pylint: disable=unused-argument
234233
"""Create vector index with index params.
@@ -261,7 +260,7 @@ def drop_index(
261260
self,
262261
collection_name: str,
263262
index_name: str,
264-
timeout: Optional[float] = None,
263+
timeout: float | None = None,
265264
**kwargs,
266265
): # pylint: disable=unused-argument
267266
"""Drop index on specified collection.
@@ -349,17 +348,17 @@ def _parse_value_for_text_sql(
349348
def search(
350349
self,
351350
collection_name: str,
352-
data: Union[list, dict],
351+
data: list | dict,
353352
anns_field: str,
354353
with_dist: bool = False,
355354
flter=None,
356355
limit: int = 10,
357-
output_fields: Optional[List[str]] = None,
358-
search_params: Optional[dict] = None,
359-
timeout: Optional[float] = None, # pylint: disable=unused-argument
360-
partition_names: Optional[List[str]] = None,
356+
output_fields: list[str] | None = None,
357+
search_params: dict | None = None,
358+
timeout: float | None = None, # pylint: disable=unused-argument
359+
partition_names: list[str] | None = None,
361360
**kwargs, # pylint: disable=unused-argument
362-
) -> List[dict]:
361+
) -> list[dict]:
363362
"""Perform ann search.
364363
Note: OceanBase does not support batch search now. `data` & the return value is not a batch.
365364
@@ -467,11 +466,11 @@ def query(
467466
self,
468467
collection_name: str,
469468
flter=None,
470-
output_fields: Optional[List[str]] = None,
471-
timeout: Optional[float] = None, # pylint: disable=unused-argument
472-
partition_names: Optional[List[str]] = None,
469+
output_fields: list[str] | None = None,
470+
timeout: float | None = None, # pylint: disable=unused-argument
471+
partition_names: list[str] | None = None,
473472
**kwargs, # pylint: disable=unused-argument
474-
) -> List[dict]:
473+
) -> list[dict]:
475474
"""Query records.
476475
477476
Args:
@@ -532,12 +531,12 @@ def query(
532531
def get(
533532
self,
534533
collection_name: str,
535-
ids: Union[list, str, int] = None,
536-
output_fields: Optional[List[str]] = None,
537-
timeout: Optional[float] = None, # pylint: disable=unused-argument
538-
partition_names: Optional[List[str]] = None,
534+
ids: list | str | int = None,
535+
output_fields: list[str] | None = None,
536+
timeout: float | None = None, # pylint: disable=unused-argument
537+
partition_names: list[str] | None = None,
539538
**kwargs, # pylint: disable=unused-argument
540-
) -> List[dict]:
539+
) -> list[dict]:
541540
"""Get records with specified primary field `ids`.
542541
543542
Args:
@@ -575,7 +574,7 @@ def get(
575574
)
576575
if isinstance(ids, list):
577576
where_in_clause = table.c[pkey_names[0]].in_(ids)
578-
elif isinstance(ids, (str, int)):
577+
elif isinstance(ids, str | int):
579578
where_in_clause = table.c[pkey_names[0]].in_([ids])
580579
else:
581580
raise TypeError("'ids' is not a list/str/int")
@@ -610,10 +609,10 @@ def get(
610609
def delete(
611610
self,
612611
collection_name: str,
613-
ids: Optional[Union[list, str, int]] = None,
614-
timeout: Optional[float] = None, # pylint: disable=unused-argument
612+
ids: list | str | int | None = None,
613+
timeout: float | None = None, # pylint: disable=unused-argument
615614
flter=None,
616-
partition_name: Optional[str] = "",
615+
partition_name: str | None = "",
617616
**kwargs, # pylint: disable=unused-argument
618617
) -> dict:
619618
"""Delete data in collection.
@@ -648,7 +647,7 @@ def delete(
648647
)
649648
if isinstance(ids, list):
650649
where_in_clause = table.c[pkey_names[0]].in_(ids)
651-
elif isinstance(ids, (str, int)):
650+
elif isinstance(ids, str | int):
652651
where_in_clause = table.c[pkey_names[0]].in_([ids])
653652
else:
654653
raise TypeError("'ids' is not a list/str/int")
@@ -672,9 +671,9 @@ def delete(
672671
def insert(
673672
self,
674673
collection_name: str,
675-
data: Union[Dict, List[Dict]],
676-
timeout: Optional[float] = None,
677-
partition_name: Optional[str] = "",
674+
data: dict | list[dict],
675+
timeout: float | None = None,
676+
partition_name: str | None = "",
678677
) -> (
679678
None
680679
): # pylint: disable=unused-argument
@@ -700,10 +699,10 @@ def insert(
700699
def upsert(
701700
self,
702701
collection_name: str,
703-
data: Union[Dict, List[Dict]],
704-
timeout: Optional[float] = None, # pylint: disable=unused-argument
705-
partition_name: Optional[str] = "",
706-
) -> List[Union[str, int]]:
702+
data: dict | list[dict],
703+
timeout: float | None = None, # pylint: disable=unused-argument
704+
partition_name: str | None = "",
705+
) -> list[str | int]:
707706
"""Update data in table. If primary key is duplicated, replace it.
708707
709708
Args:

0 commit comments

Comments
 (0)