Skip to content

Commit 79f45bc

Browse files
fix style
1 parent d173b4e commit 79f45bc

File tree

7 files changed

+92
-75
lines changed

7 files changed

+92
-75
lines changed

docs/src/whatsnew.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This document outlines features and improvements from each release.
1111
v1.14.0 - May 28, 2025
1212
------------------------
1313
* Add ``vector_db`` property to a ``Connection`` object to get the vectorstor API to the current database
14-
* Add ``vector_db(...)`` function to connect to a database and optain a vectorstor API
14+
* Add ``vector_db(...)`` function to connect to a database and optain a vectorstor API
1515

1616
v1.13.0 - April 16, 2025
1717
------------------------

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ parsimonious
33
PyJWT
44
requests
55
setuptools
6+
singlestore-vecorstore
67
sqlparams
78
tomli>=1.1.0; python_version < '3.11'
89
typing_extensions<=4.13.2
910
wheel
10-
singlestore-vecorstore>=0.1.1

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ install_requires =
2424
parsimonious
2525
requests
2626
setuptools
27+
singlestore-vecorstore
2728
sqlparams
2829
wheel
29-
singlestore-vecorstore>=0.1.1
3030
tomli>=1.1.0;python_version < '3.11'
3131
typing-extensions<=4.13.2;python_version < '3.11'
3232
python_requires = >=3.8

singlestoredb/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131
Date, Time, Timestamp, DateFromTicks, TimeFromTicks, TimestampFromTicks,
3232
Binary, STRING, BINARY, NUMBER, DATETIME, ROWID,
3333
)
34-
from .vectorstore import vector_db
34+
from .vectorstore import (
35+
vector_db, IndexInterface, IndexList, IndexModel, MatchTypedDict,
36+
Metric, IndexStatsTypedDict, NamespaceStatsTypedDict, Vector,
37+
VectorDictMetadataValue, VectorMetadataTypedDict, VectorTuple,
38+
VectorTupleWithMetadata, DeletionProtection, AndFilter, EqFilter,
39+
ExactMatchFilter, FilterTypedDict, GteFilter, GtFilter, InFilter,
40+
LteFilter, LtFilter, NeFilter, NinFilter, OrFilter, SimpleFilter,
41+
)
42+
3543

3644
#
3745
# This function is defined here to prevent the side-effect of

singlestoredb/connection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
"""SingleStoreDB connections and cursors."""
3-
43
import abc
54
import inspect
65
import io
@@ -24,7 +23,6 @@
2423
from urllib.parse import unquote_plus
2524
from urllib.parse import urlparse
2625

27-
2826
import sqlparams
2927
try:
3028
from pandas import DataFrame
@@ -1293,13 +1291,14 @@ def show(self) -> ShowAccessor:
12931291
@property
12941292
def vector_db(self) -> Any:
12951293
"""
1296-
Get vectorstore API accessor
1294+
Get vectorstore API accessor
12971295
"""
12981296
from vectorstore import VectorDB
12991297
if not hasattr(self, '_vector_db'):
13001298
self._vector_db = VectorDB(connection=self)
13011299
return self._vector_db
13021300

1301+
13031302
#
13041303
# NOTE: When adding parameters to this function, you should always
13051304
# make the value optional with a default of None. The options
Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import os
22
import unittest
33

4+
from vectorstore import VectorDB
5+
46
import singlestoredb as s2
57
from . import utils
68

7-
from vectorstore import VectorDB
89

910
class TestVectorDB(unittest.TestCase):
1011

@@ -14,28 +15,34 @@ class TestVectorDB(unittest.TestCase):
1415
dbexisted: bool = False
1516

1617
@classmethod
17-
def setUpClass(cls):
18+
def setUpClass(cls) -> None:
1819
sql_file = os.path.join(os.path.dirname(__file__), 'empty.sql')
19-
cls.dbname, cls.dbexisted = utils.load_sql(sql_file)
20+
cls.dbname, cls.dbexisted = utils.load_sql(sql_file) # type: ignore
2021

2122
@classmethod
22-
def tearDownClass(cls):
23+
def tearDownClass(cls) -> None:
2324
if not cls.dbexisted:
24-
utils.drop_database(cls.dbname)
25+
utils.drop_database(cls.dbname) # type: ignore
2526

26-
def test_vectordb_from_params(self):
27+
def test_vectordb_from_params(self) -> None:
2728
db: VectorDB = s2.vector_db(database=type(self).dbname)
28-
index = db.create_index(name="test_index", dimension=3, tags={"name": "test_tag"})
29-
assert index.name == "test_index"
29+
index = db.create_index(
30+
name='test_index', dimension=3,
31+
tags={'name': 'test_tag'},
32+
)
33+
assert index.name == 'test_index'
3034
assert index.dimension == 3
31-
assert index.tags == {"name": "test_tag"}
32-
assert db.has_index("test_index")
35+
assert index.tags == {'name': 'test_tag'}
36+
assert db.has_index('test_index')
3337

34-
def test_vectordb_from_connection(self):
38+
def test_vectordb_from_connection(self) -> None:
3539
with s2.connect(database=type(self).dbname) as conn:
3640
db: VectorDB = conn.vector_db
37-
index = db.create_index(name="test_index_1", dimension=4, tags={"name": "test_tag"})
38-
assert index.name == "test_index_1"
41+
index = db.create_index(
42+
name='test_index_1',
43+
dimension=4, tags={'name': 'test_tag'},
44+
)
45+
assert index.name == 'test_index_1'
3946
assert index.dimension == 4
40-
assert index.tags == {"name": "test_tag"}
41-
assert db.has_index("test_index_1")
47+
assert index.tags == {'name': 'test_tag'}
48+
assert db.has_index('test_index_1')

singlestoredb/vectorstore.py

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
from __future__ import annotations
2-
from typing import Optional, Dict, Callable, Any
1+
from typing import Any
2+
from typing import Callable
3+
from typing import Dict
4+
from typing import Optional
5+
6+
from vectorstore import AndFilter # noqa: F401
7+
from vectorstore import DeletionProtection # noqa: F401
8+
from vectorstore import EqFilter # noqa: F401
9+
from vectorstore import ExactMatchFilter # noqa: F401
10+
from vectorstore import FilterTypedDict # noqa: F401
11+
from vectorstore import GteFilter # noqa: F401
12+
from vectorstore import GtFilter # noqa: F401
13+
from vectorstore import IndexInterface # noqa: F401
14+
from vectorstore import IndexList # noqa: F401
15+
from vectorstore import IndexModel # noqa: F401
16+
from vectorstore import IndexStatsTypedDict # noqa: F401
17+
from vectorstore import InFilter # noqa: F401
18+
from vectorstore import LteFilter # noqa: F401
19+
from vectorstore import LtFilter # noqa: F401
20+
from vectorstore import MatchTypedDict # noqa: F401
21+
from vectorstore import Metric # noqa: F401
22+
from vectorstore import NamespaceStatsTypedDict # noqa: F401
23+
from vectorstore import NeFilter # noqa: F401
24+
from vectorstore import NinFilter # noqa: F401
25+
from vectorstore import OrFilter # noqa: F401
26+
from vectorstore import SimpleFilter # noqa: F401
27+
from vectorstore import Vector # noqa: F401
28+
from vectorstore import VectorDictMetadataValue # noqa: F401
29+
from vectorstore import VectorMetadataTypedDict # noqa: F401
30+
from vectorstore import VectorTuple # noqa: F401
31+
from vectorstore import VectorTupleWithMetadata # noqa: F401
332

4-
from vectorstore import (
5-
IndexInterface,
6-
IndexList,
7-
IndexModel,
8-
MatchTypedDict,
9-
Metric,
10-
IndexStatsTypedDict,
11-
NamespaceStatsTypedDict,
12-
Vector,
13-
VectorDictMetadataValue,
14-
VectorMetadataTypedDict,
15-
VectorTuple,
16-
VectorTupleWithMetadata,
17-
DeletionProtection,
18-
AndFilter,
19-
EqFilter,
20-
ExactMatchFilter,
21-
FilterTypedDict,
22-
GteFilter,
23-
GtFilter,
24-
InFilter,
25-
LteFilter,
26-
LtFilter,
27-
NeFilter,
28-
NinFilter,
29-
OrFilter,
30-
SimpleFilter
31-
)
3233

3334
def vector_db(
3435
host: Optional[str] = None, user: Optional[str] = None,
@@ -62,9 +63,9 @@ def vector_db(
6263
pool_size: Optional[int] = 5,
6364
max_overflow: Optional[int] = 10,
6465
timeout: Optional[float] = 30,
65-
) -> "VectorDB":
66+
) -> Any:
6667
"""
67-
Return a vectorstore API connection.
68+
Return a vectorstore API connection.
6869
Database should be specified in the URL or as a keyword.
6970
7071
Parameters
@@ -87,7 +88,7 @@ def vector_db(
8788
Database port. This defaults to 3306 for non-HTTP connections, 80
8889
for HTTP connections, and 443 for HTTPS connections.
8990
database : str, optional
90-
Database name.
91+
Database name.
9192
pure_python : bool, optional
9293
Use the connector in pure Python mode
9394
local_infile : bool, optional
@@ -167,23 +168,25 @@ def vector_db(
167168
168169
"""
169170
from vectorstore import VectorDB
170-
return VectorDB(host=host, user=user, password=password, port=port,
171-
database=database, driver=driver, pure_python=pure_python,
172-
local_infile=local_infile, charset=charset,
173-
ssl_key=ssl_key, ssl_cert=ssl_cert, ssl_ca=ssl_ca,
174-
ssl_disabled=ssl_disabled, ssl_cipher=ssl_cipher,
175-
ssl_verify_cert=ssl_verify_cert,
176-
tls_sni_servername=tls_sni_servername,
177-
ssl_verify_identity=ssl_verify_identity, conv=conv,
178-
credential_type=credential_type, autocommit=autocommit,
179-
results_type=results_type, buffered=buffered,
180-
results_format=results_format, program_name=program_name,
181-
conn_attrs=conn_attrs, multi_statements=multi_statements,
182-
client_found_rows=client_found_rows,
183-
connect_timeout=connect_timeout, nan_as_null=nan_as_null,
184-
inf_as_null=inf_as_null, encoding_errors=encoding_errors,
185-
track_env=track_env,
186-
enable_extended_data_types=enable_extended_data_types,
187-
vector_data_format=vector_data_format,
188-
parse_json=parse_json, pool_size=pool_size,
189-
max_overflow=max_overflow, timeout=timeout)
171+
return VectorDB(
172+
host=host, user=user, password=password, port=port,
173+
database=database, driver=driver, pure_python=pure_python,
174+
local_infile=local_infile, charset=charset,
175+
ssl_key=ssl_key, ssl_cert=ssl_cert, ssl_ca=ssl_ca,
176+
ssl_disabled=ssl_disabled, ssl_cipher=ssl_cipher,
177+
ssl_verify_cert=ssl_verify_cert,
178+
tls_sni_servername=tls_sni_servername,
179+
ssl_verify_identity=ssl_verify_identity, conv=conv,
180+
credential_type=credential_type, autocommit=autocommit,
181+
results_type=results_type, buffered=buffered,
182+
results_format=results_format, program_name=program_name,
183+
conn_attrs=conn_attrs, multi_statements=multi_statements,
184+
client_found_rows=client_found_rows,
185+
connect_timeout=connect_timeout, nan_as_null=nan_as_null,
186+
inf_as_null=inf_as_null, encoding_errors=encoding_errors,
187+
track_env=track_env,
188+
enable_extended_data_types=enable_extended_data_types,
189+
vector_data_format=vector_data_format,
190+
parse_json=parse_json, pool_size=pool_size,
191+
max_overflow=max_overflow, timeout=timeout,
192+
)

0 commit comments

Comments
 (0)