mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-23 21:39:57 +00:00
Compare commits
12 Commits
docs/mcp
...
python-v0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
204a075be9 | ||
|
|
d6d7ad3b06 | ||
|
|
e58d64c286 | ||
|
|
76cbd18c46 | ||
|
|
4abb38ac70 | ||
|
|
cc7bc5011d | ||
|
|
8193183304 | ||
|
|
cf28b58b7d | ||
|
|
e3b7ee47b9 | ||
|
|
97c9c906e4 | ||
|
|
358f86b9c6 | ||
|
|
5489e215a3 |
@@ -1,5 +1,5 @@
|
|||||||
[tool.bumpversion]
|
[tool.bumpversion]
|
||||||
current_version = "0.9.0"
|
current_version = "0.9.0-beta.3"
|
||||||
parse = """(?x)
|
parse = """(?x)
|
||||||
(?P<major>0|[1-9]\\d*)\\.
|
(?P<major>0|[1-9]\\d*)\\.
|
||||||
(?P<minor>0|[1-9]\\d*)\\.
|
(?P<minor>0|[1-9]\\d*)\\.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "lancedb-python"
|
name = "lancedb-python"
|
||||||
version = "0.9.0"
|
version = "0.9.0-beta.3"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description = "Python bindings for LanceDB"
|
description = "Python bindings for LanceDB"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ dependencies = [
|
|||||||
"packaging",
|
"packaging",
|
||||||
"cachetools",
|
"cachetools",
|
||||||
"overrides>=0.7",
|
"overrides>=0.7",
|
||||||
|
"urllib3==1.26.19"
|
||||||
]
|
]
|
||||||
description = "lancedb"
|
description = "lancedb"
|
||||||
authors = [{ name = "LanceDB Devs", email = "dev@lancedb.com" }]
|
authors = [{ name = "LanceDB Devs", email = "dev@lancedb.com" }]
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ def connect(
|
|||||||
host_override: Optional[str] = None,
|
host_override: Optional[str] = None,
|
||||||
read_consistency_interval: Optional[timedelta] = None,
|
read_consistency_interval: Optional[timedelta] = None,
|
||||||
request_thread_pool: Optional[Union[int, ThreadPoolExecutor]] = None,
|
request_thread_pool: Optional[Union[int, ThreadPoolExecutor]] = None,
|
||||||
|
storage_options: Optional[Dict[str, str]] = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> DBConnection:
|
) -> DBConnection:
|
||||||
"""Connect to a LanceDB database.
|
"""Connect to a LanceDB database.
|
||||||
@@ -70,6 +71,9 @@ def connect(
|
|||||||
executor will be used for making requests. This is for LanceDB Cloud
|
executor will be used for making requests. This is for LanceDB Cloud
|
||||||
only and is only used when making batch requests (i.e., passing in
|
only and is only used when making batch requests (i.e., passing in
|
||||||
multiple queries to the search method at once).
|
multiple queries to the search method at once).
|
||||||
|
storage_options: dict, optional
|
||||||
|
Additional options for the storage backend. See available options at
|
||||||
|
https://lancedb.github.io/lancedb/guides/storage/
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
@@ -105,12 +109,16 @@ def connect(
|
|||||||
region,
|
region,
|
||||||
host_override,
|
host_override,
|
||||||
request_thread_pool=request_thread_pool,
|
request_thread_pool=request_thread_pool,
|
||||||
|
storage_options=storage_options,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
if kwargs:
|
if kwargs:
|
||||||
raise ValueError(f"Unknown keyword arguments: {kwargs}")
|
raise ValueError(f"Unknown keyword arguments: {kwargs}")
|
||||||
return LanceDBConnection(uri, read_consistency_interval=read_consistency_interval)
|
return LanceDBConnection(
|
||||||
|
uri,
|
||||||
|
read_consistency_interval=read_consistency_interval,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def connect_async(
|
async def connect_async(
|
||||||
|
|||||||
@@ -55,11 +55,13 @@ class RestfulLanceDBClient:
|
|||||||
region: str
|
region: str
|
||||||
api_key: Credential
|
api_key: Credential
|
||||||
host_override: Optional[str] = attrs.field(default=None)
|
host_override: Optional[str] = attrs.field(default=None)
|
||||||
|
db_prefix: Optional[str] = attrs.field(default=None)
|
||||||
|
|
||||||
closed: bool = attrs.field(default=False, init=False)
|
closed: bool = attrs.field(default=False, init=False)
|
||||||
|
|
||||||
connection_timeout: float = attrs.field(default=120.0, kw_only=True)
|
connection_timeout: float = attrs.field(default=120.0, kw_only=True)
|
||||||
read_timeout: float = attrs.field(default=300.0, kw_only=True)
|
read_timeout: float = attrs.field(default=300.0, kw_only=True)
|
||||||
|
storage_options: Optional[Dict[str, str]] = attrs.field(default=None, kw_only=True)
|
||||||
|
|
||||||
@functools.cached_property
|
@functools.cached_property
|
||||||
def session(self) -> requests.Session:
|
def session(self) -> requests.Session:
|
||||||
@@ -92,6 +94,18 @@ class RestfulLanceDBClient:
|
|||||||
headers["Host"] = f"{self.db_name}.{self.region}.api.lancedb.com"
|
headers["Host"] = f"{self.db_name}.{self.region}.api.lancedb.com"
|
||||||
if self.host_override:
|
if self.host_override:
|
||||||
headers["x-lancedb-database"] = self.db_name
|
headers["x-lancedb-database"] = self.db_name
|
||||||
|
if self.storage_options:
|
||||||
|
if self.storage_options.get("account_name") is not None:
|
||||||
|
headers["x-azure-storage-account-name"] = self.storage_options[
|
||||||
|
"account_name"
|
||||||
|
]
|
||||||
|
if self.storage_options.get("azure_storage_account_name") is not None:
|
||||||
|
headers["x-azure-storage-account-name"] = self.storage_options[
|
||||||
|
"azure_storage_account_name"
|
||||||
|
]
|
||||||
|
if self.db_prefix:
|
||||||
|
headers["x-lancedb-database-prefix"] = self.db_prefix
|
||||||
|
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -245,7 +259,6 @@ def retry_adapter(options: Dict[str, Any]) -> HTTPAdapter:
|
|||||||
connect=connect_retries,
|
connect=connect_retries,
|
||||||
read=read_retries,
|
read=read_retries,
|
||||||
backoff_factor=backoff_factor,
|
backoff_factor=backoff_factor,
|
||||||
backoff_jitter=backoff_jitter,
|
|
||||||
status_forcelist=statuses,
|
status_forcelist=statuses,
|
||||||
allowed_methods=methods,
|
allowed_methods=methods,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import inspect
|
|||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from typing import Iterable, List, Optional, Union
|
from typing import Dict, Iterable, List, Optional, Union
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from cachetools import TTLCache
|
from cachetools import TTLCache
|
||||||
@@ -44,20 +44,25 @@ class RemoteDBConnection(DBConnection):
|
|||||||
request_thread_pool: Optional[ThreadPoolExecutor] = None,
|
request_thread_pool: Optional[ThreadPoolExecutor] = None,
|
||||||
connection_timeout: float = 120.0,
|
connection_timeout: float = 120.0,
|
||||||
read_timeout: float = 300.0,
|
read_timeout: float = 300.0,
|
||||||
|
storage_options: Optional[Dict[str, str]] = None,
|
||||||
):
|
):
|
||||||
"""Connect to a remote LanceDB database."""
|
"""Connect to a remote LanceDB database."""
|
||||||
parsed = urlparse(db_url)
|
parsed = urlparse(db_url)
|
||||||
if parsed.scheme != "db":
|
if parsed.scheme != "db":
|
||||||
raise ValueError(f"Invalid scheme: {parsed.scheme}, only accepts db://")
|
raise ValueError(f"Invalid scheme: {parsed.scheme}, only accepts db://")
|
||||||
self.db_name = parsed.netloc
|
self.db_name = parsed.netloc
|
||||||
|
prefix = parsed.path.lstrip("/")
|
||||||
|
self.db_prefix = None if not prefix else prefix
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
self._client = RestfulLanceDBClient(
|
self._client = RestfulLanceDBClient(
|
||||||
self.db_name,
|
self.db_name,
|
||||||
region,
|
region,
|
||||||
api_key,
|
api_key,
|
||||||
host_override,
|
host_override,
|
||||||
|
self.db_prefix,
|
||||||
connection_timeout=connection_timeout,
|
connection_timeout=connection_timeout,
|
||||||
read_timeout=read_timeout,
|
read_timeout=read_timeout,
|
||||||
|
storage_options=storage_options,
|
||||||
)
|
)
|
||||||
self._request_thread_pool = request_thread_pool
|
self._request_thread_pool = request_thread_pool
|
||||||
self._table_cache = TTLCache(maxsize=10000, ttl=300)
|
self._table_cache = TTLCache(maxsize=10000, ttl=300)
|
||||||
|
|||||||
@@ -735,7 +735,7 @@ def test_create_scalar_index(db):
|
|||||||
indices = table.to_lance().list_indices()
|
indices = table.to_lance().list_indices()
|
||||||
assert len(indices) == 1
|
assert len(indices) == 1
|
||||||
scalar_index = indices[0]
|
scalar_index = indices[0]
|
||||||
assert scalar_index["type"] == "Scalar"
|
assert scalar_index["type"] == "BTree"
|
||||||
|
|
||||||
# Confirm that prefiltering still works with the scalar index column
|
# Confirm that prefiltering still works with the scalar index column
|
||||||
results = table.search().where("x = 'c'").to_arrow()
|
results = table.search().where("x = 'c'").to_arrow()
|
||||||
|
|||||||
Reference in New Issue
Block a user