mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
Merge main into codex/update-lance-15-0-0-beta-19
This commit is contained in:
+2
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lancedb-python"
|
||||
version = "0.42.0-beta.11"
|
||||
version = "0.42.0-beta.12"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
description = "Python bindings for LanceDB"
|
||||
@@ -37,6 +37,7 @@ pyo3-async-runtimes = { version = "0.29", features = [
|
||||
"tokio-runtime",
|
||||
] }
|
||||
reqwest.workspace = true
|
||||
rattler_conda_types = { version = "0.58.3", default-features = false }
|
||||
pin-project.workspace = true
|
||||
futures.workspace = true
|
||||
serde.workspace = true
|
||||
|
||||
@@ -1227,6 +1227,7 @@ async def connect_catalog(
|
||||
sql_host_override: Optional[str] = None,
|
||||
read_consistency_interval: Optional[float] = None,
|
||||
oauth_config: Optional[Any] = None,
|
||||
storage_options: Optional[dict[str, str]] = None,
|
||||
) -> Catalog: ...
|
||||
|
||||
class NameListing:
|
||||
@@ -1310,3 +1311,4 @@ class AuthzObject:
|
||||
def __repr__(self) -> str: ...
|
||||
|
||||
def validate_function_retry_policy(json: str) -> None: ...
|
||||
def _validate_conda_requirement(requirement: str) -> None: ...
|
||||
|
||||
@@ -3,13 +3,17 @@
|
||||
|
||||
"""Remote catalogs manage databases."""
|
||||
|
||||
from functools import cached_property
|
||||
import os
|
||||
import warnings
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import timedelta
|
||||
from functools import cached_property
|
||||
from typing import Any, AsyncIterator, Iterator, Optional, Union
|
||||
|
||||
from . import _lancedb
|
||||
from .background_loop import LOOP
|
||||
from .authz import AsyncAuthorization, Authorization
|
||||
from .common import URI, sanitize_uri
|
||||
from .db import AsyncConnection, DBConnection
|
||||
from .remote import ClientConfig, OAuthConfig
|
||||
from .remote.db import RemoteDBConnection
|
||||
@@ -163,12 +167,14 @@ class Catalog:
|
||||
client_config=None,
|
||||
sql_host_override: Optional[str] = None,
|
||||
oauth_config: Optional[OAuthConfig] = None,
|
||||
storage_options: Optional[dict[str, str]] = None,
|
||||
):
|
||||
self._inner = inner
|
||||
self._api_key = api_key
|
||||
self._client_config = client_config
|
||||
self._sql_host_override = sql_host_override
|
||||
self._oauth_config = oauth_config
|
||||
self._storage_options = storage_options
|
||||
|
||||
@cached_property
|
||||
def authz(self) -> Authorization:
|
||||
@@ -198,6 +204,7 @@ class Catalog:
|
||||
self._client_config,
|
||||
self._oauth_config,
|
||||
self._sql_host_override,
|
||||
self._storage_options,
|
||||
)
|
||||
|
||||
def list_databases(
|
||||
@@ -227,28 +234,71 @@ class Catalog:
|
||||
|
||||
|
||||
async def connect_catalog_async(
|
||||
endpoint: str,
|
||||
uri: Optional[URI] = None,
|
||||
*,
|
||||
api_key: Optional[str] = None,
|
||||
client_config: Optional[Union[ClientConfig, dict[str, Any]]] = None,
|
||||
region: Optional[str] = None,
|
||||
host_override: Optional[str] = None,
|
||||
sql_host_override: Optional[str] = None,
|
||||
read_consistency_interval: Optional[timedelta] = None,
|
||||
client_config: Optional[Union[ClientConfig, dict[str, Any]]] = None,
|
||||
storage_options: Optional[dict[str, str]] = None,
|
||||
session: Optional[_lancedb.Session] = None,
|
||||
manifest_enabled: bool = False,
|
||||
namespace_client_properties: Optional[dict[str, str]] = None,
|
||||
oauth_config: Optional[OAuthConfig] = None,
|
||||
) -> AsyncCatalog:
|
||||
"""Connect to an HTTP(S) server's root catalog.
|
||||
"""Connect to a server's root catalog using database connection settings.
|
||||
|
||||
``host_override`` selects the HTTP(S) catalog endpoint when provided; otherwise
|
||||
``uri`` must be an HTTP(S) endpoint. A ``db://`` URI can be shared with
|
||||
[connect_async][lancedb.connect_async] when ``host_override`` is set: the URI's
|
||||
database is ignored and requests target the root catalog.
|
||||
|
||||
``region`` is ignored with a warning when supplied. Catalog connections use
|
||||
the explicit endpoint rather than a region-derived Cloud (legacy) endpoint.
|
||||
``api_key`` defaults to the ``LANCEDB_API_KEY`` environment variable.
|
||||
Embedded-only ``session``, ``manifest_enabled`` and
|
||||
``namespace_client_properties`` are not supported.
|
||||
|
||||
Root requests omit database-selection headers. API key, client configuration,
|
||||
OAuth, and table read consistency settings are inherited by opened databases.
|
||||
OAuth, storage options, and table read consistency settings are inherited by
|
||||
opened databases.
|
||||
Database names containing slashes remain single logical names.
|
||||
Set ``sql_host_override`` to the SQL service endpoint to execute SQL through
|
||||
returned connections when the catalog endpoint uses HTTPS.
|
||||
"""
|
||||
if region is not None:
|
||||
warnings.warn(
|
||||
"region is ignored by connect_catalog_async; the catalog endpoint "
|
||||
"is selected by host_override or uri.",
|
||||
UserWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
for name, value in (
|
||||
("session", session),
|
||||
("manifest_enabled", manifest_enabled or None),
|
||||
("namespace_client_properties", namespace_client_properties),
|
||||
):
|
||||
if value is not None:
|
||||
raise NotImplementedError(
|
||||
f"{name} is not supported for catalog connections"
|
||||
)
|
||||
endpoint = host_override if host_override is not None else uri
|
||||
if endpoint is None:
|
||||
raise ValueError("uri or host_override is required for catalog connections")
|
||||
if isinstance(client_config, dict):
|
||||
client_config = ClientConfig(**client_config)
|
||||
if client_config is None:
|
||||
client_config = ClientConfig()
|
||||
if (
|
||||
api_key is None
|
||||
and oauth_config is None
|
||||
and client_config.header_provider is None
|
||||
):
|
||||
api_key = os.environ.get("LANCEDB_API_KEY")
|
||||
inner = await _lancedb.connect_catalog(
|
||||
endpoint,
|
||||
sanitize_uri(endpoint),
|
||||
api_key=api_key,
|
||||
client_config=client_config,
|
||||
sql_host_override=sql_host_override,
|
||||
@@ -258,32 +308,115 @@ async def connect_catalog_async(
|
||||
else None
|
||||
),
|
||||
oauth_config=oauth_config,
|
||||
storage_options=storage_options,
|
||||
)
|
||||
return AsyncCatalog(inner)
|
||||
|
||||
|
||||
def connect_catalog(
|
||||
endpoint: str,
|
||||
uri: Optional[URI] = None,
|
||||
*,
|
||||
api_key: Optional[str] = None,
|
||||
client_config: Optional[Union[ClientConfig, dict[str, Any]]] = None,
|
||||
region: Optional[str] = None,
|
||||
host_override: Optional[str] = None,
|
||||
sql_host_override: Optional[str] = None,
|
||||
read_consistency_interval: Optional[timedelta] = None,
|
||||
request_thread_pool: Optional[Union[int, ThreadPoolExecutor]] = None,
|
||||
client_config: Optional[Union[ClientConfig, dict[str, Any]]] = None,
|
||||
storage_options: Optional[dict[str, str]] = None,
|
||||
session: Optional[_lancedb.Session] = None,
|
||||
manifest_enabled: bool = False,
|
||||
namespace_client_impl: Optional[str] = None,
|
||||
namespace_client_properties: Optional[dict[str, str]] = None,
|
||||
namespace_client_pushdown_operations: Optional[list[str]] = None,
|
||||
oauth_config: Optional[OAuthConfig] = None,
|
||||
**kwargs: Any,
|
||||
) -> Catalog:
|
||||
"""Connect synchronously to an HTTP(S) server's root catalog.
|
||||
"""Connect synchronously to a root catalog using database connection settings.
|
||||
|
||||
See [connect_catalog_async][lancedb.connect_catalog_async] for options.
|
||||
The inputs match [connect][lancedb.connect]; ``region`` is ignored with a
|
||||
warning when supplied. Namespace client options and embedded session settings
|
||||
are not supported. ``request_thread_pool`` is deprecated and unused, as in
|
||||
``connect``.
|
||||
Local filesystem and object-store catalogs are not supported.
|
||||
|
||||
Examples
|
||||
--------
|
||||
```python
|
||||
settings = {"api_key": "secret", "host_override": "https://my-server.example"}
|
||||
catalog = lancedb.connect_catalog("db://analytics", **settings)
|
||||
db = lancedb.connect("db://analytics", **settings)
|
||||
```
|
||||
"""
|
||||
unknown_kwargs = {
|
||||
key: value
|
||||
for key, value in kwargs.items()
|
||||
if key not in ("connection_timeout", "read_timeout")
|
||||
}
|
||||
if unknown_kwargs:
|
||||
raise ValueError(f"Unknown keyword arguments: {unknown_kwargs}")
|
||||
for name, value in (
|
||||
("namespace_client_impl", namespace_client_impl),
|
||||
("namespace_client_pushdown_operations", namespace_client_pushdown_operations),
|
||||
):
|
||||
if value is not None:
|
||||
raise NotImplementedError(
|
||||
f"{name} is not supported for catalog connections"
|
||||
)
|
||||
if region is not None:
|
||||
warnings.warn(
|
||||
"region is ignored by connect_catalog; the catalog endpoint "
|
||||
"is selected by host_override or uri.",
|
||||
UserWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
if request_thread_pool is not None:
|
||||
warnings.warn(
|
||||
"request_thread_pool is no longer used and will be removed in "
|
||||
"a future release.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
if isinstance(client_config, dict):
|
||||
client_config = ClientConfig(**client_config)
|
||||
if client_config is None:
|
||||
client_config = ClientConfig()
|
||||
for name, field in (
|
||||
("connection_timeout", "connect_timeout"),
|
||||
("read_timeout", "read_timeout"),
|
||||
):
|
||||
if kwargs.get(name) is not None:
|
||||
warnings.warn(
|
||||
f"{name} is deprecated and will be removed in a future release. "
|
||||
f"Please use client_config.timeout_config.{field} instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
setattr(
|
||||
client_config.timeout_config,
|
||||
field,
|
||||
timedelta(seconds=kwargs[name]),
|
||||
)
|
||||
if (
|
||||
api_key is None
|
||||
and oauth_config is None
|
||||
and client_config.header_provider is None
|
||||
):
|
||||
api_key = os.environ.get("LANCEDB_API_KEY")
|
||||
return Catalog(
|
||||
LOOP.run(
|
||||
connect_catalog_async(
|
||||
endpoint,
|
||||
uri,
|
||||
api_key=api_key,
|
||||
host_override=host_override,
|
||||
client_config=client_config,
|
||||
sql_host_override=sql_host_override,
|
||||
read_consistency_interval=read_consistency_interval,
|
||||
storage_options=storage_options,
|
||||
session=session,
|
||||
manifest_enabled=manifest_enabled,
|
||||
namespace_client_properties=namespace_client_properties,
|
||||
oauth_config=oauth_config,
|
||||
)
|
||||
),
|
||||
@@ -291,4 +424,5 @@ def connect_catalog(
|
||||
client_config=client_config,
|
||||
sql_host_override=sql_host_override,
|
||||
oauth_config=oauth_config,
|
||||
storage_options=storage_options,
|
||||
)
|
||||
|
||||
+54
-12
@@ -67,7 +67,7 @@ from .graph import (
|
||||
PropertyGraph,
|
||||
_definition_json,
|
||||
)
|
||||
from .job import AsyncJob, Job, _typed_job
|
||||
from .job import AsyncJob, Job, _opened_job, _typed_job
|
||||
from .storage_integration import SecretReference, StorageIntegrationInfo
|
||||
from .sql import AsyncQuery as AsyncSqlQuery
|
||||
from .sql import Query as SqlQuery
|
||||
@@ -322,6 +322,9 @@ class DBConnection(EnforceOverrides):
|
||||
def table_exists(self, table_id: List[str]) -> bool:
|
||||
"""Check if a table exists.
|
||||
|
||||
Use this method instead of checking membership in
|
||||
``list_tables().tables``, which contains only one page of table names.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
table_id: List[str]
|
||||
@@ -331,12 +334,20 @@ class DBConnection(EnforceOverrides):
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
True if the table exists, False otherwise.
|
||||
True if the table exists, False if it is not found.
|
||||
Other errors, including permission errors, are propagated.
|
||||
|
||||
Raises
|
||||
------
|
||||
NotImplementedError
|
||||
If the connection type does not support namespace operations.
|
||||
If the connection type does not support table existence checks.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> def check_table(conn):
|
||||
... root_exists = conn.table_exists(["events"])
|
||||
... nested_exists = conn.table_exists(["analytics", "events"])
|
||||
... return root_exists, nested_exists
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"Namespace operations are not supported for this connection type"
|
||||
@@ -348,7 +359,11 @@ class DBConnection(EnforceOverrides):
|
||||
page_token: Optional[str] = None,
|
||||
limit: Optional[int] = None,
|
||||
) -> TableListing:
|
||||
"""List tables in this database, one page at a time.
|
||||
"""Iterate over all tables in this database, fetching pages as needed.
|
||||
|
||||
``list_tables().tables`` contains only the first page (100 names by
|
||||
default). Use ``list(list_tables())`` to collect all names, or
|
||||
``table_exists([name])`` to check whether a particular table exists.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -934,7 +949,7 @@ class DBConnection(EnforceOverrides):
|
||||
|
||||
def __contains__(self, name: str) -> bool:
|
||||
"""Return whether the root namespace contains the named table."""
|
||||
return name in self._all_table_names()
|
||||
return self.table_exists([name])
|
||||
|
||||
def namespace_client(self) -> LanceNamespace:
|
||||
"""Get the equivalent namespace client for this connection.
|
||||
@@ -1435,6 +1450,12 @@ class DBConnection(EnforceOverrides):
|
||||
specification, result, failure and event history, so there is no
|
||||
separate connection-level call for any of them.
|
||||
|
||||
For a column refresh, ``wait()`` returns a
|
||||
[RefreshColumnResult][lancedb.functions.RefreshColumnResult], including
|
||||
when the refresh was started through SQL. Other job types return
|
||||
``None`` from ``wait()``; their persisted result is available through
|
||||
``job.result`` after ``job.refresh()``.
|
||||
|
||||
Raises `JobNotFoundError` when the server has no such job, the way
|
||||
`open_table` does for a missing table.
|
||||
"""
|
||||
@@ -1849,6 +1870,10 @@ class LanceDBConnection(DBConnection):
|
||||
) -> DescribeNamespaceResponse:
|
||||
return LOOP.run(self._conn.describe_namespace(namespace_path=namespace_path))
|
||||
|
||||
@override
|
||||
def table_exists(self, table_id: List[str]) -> bool:
|
||||
return LOOP.run(self._conn.table_exists(table_id))
|
||||
|
||||
@override
|
||||
def list_tables(
|
||||
self,
|
||||
@@ -1856,7 +1881,11 @@ class LanceDBConnection(DBConnection):
|
||||
page_token: Optional[str] = None,
|
||||
limit: Optional[int] = None,
|
||||
) -> TableListing:
|
||||
"""List tables in this database, one page at a time.
|
||||
"""Iterate over all tables in this database, fetching pages as needed.
|
||||
|
||||
The ``tables`` attribute contains only the current page (100 names by
|
||||
default). Iterate over the listing to visit all pages, or use
|
||||
``table_exists([name])`` to check for a particular table.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -1894,7 +1923,9 @@ class LanceDBConnection(DBConnection):
|
||||
"""Get the names of all tables in the database. The names are sorted.
|
||||
|
||||
.. deprecated::
|
||||
Use :meth:`list_tables` instead, which provides proper pagination support.
|
||||
Iterate over :meth:`list_tables` to get all names, or use
|
||||
:meth:`table_exists` to check for a particular table. The listing's
|
||||
``tables`` attribute contains only one page.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -1914,7 +1945,8 @@ class LanceDBConnection(DBConnection):
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"table_names() is deprecated, use list_tables() instead",
|
||||
"table_names() is deprecated, iterate list_tables() for all names "
|
||||
"or use table_exists([name]) to check existence",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
@@ -2878,6 +2910,9 @@ class AsyncConnection(object):
|
||||
async def table_exists(self, table_id: List[str]) -> bool:
|
||||
"""Check if a table exists.
|
||||
|
||||
Use this method instead of checking membership in an awaited listing's
|
||||
``tables`` attribute, which contains only one page of table names.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
table_id: List[str]
|
||||
@@ -2903,7 +2938,11 @@ class AsyncConnection(object):
|
||||
page_token: Optional[str] = None,
|
||||
limit: Optional[int] = None,
|
||||
) -> AsyncTableListing:
|
||||
"""List tables in this database, one page at a time.
|
||||
"""Iterate over all tables in this database, fetching pages as needed.
|
||||
|
||||
The ``tables`` attribute contains only the current page (100 names by
|
||||
default). Iterate over the listing to visit all pages, or use
|
||||
``table_exists([name])`` to check for a particular table.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -2942,7 +2981,9 @@ class AsyncConnection(object):
|
||||
"""List all tables in this database, in sorted order
|
||||
|
||||
.. deprecated::
|
||||
Use :meth:`list_tables` instead, which provides proper pagination support.
|
||||
Iterate over :meth:`list_tables` to get all names, or use
|
||||
:meth:`table_exists` to check for a particular table. The listing's
|
||||
``tables`` attribute contains only one page.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -2966,7 +3007,8 @@ class AsyncConnection(object):
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"table_names() is deprecated, use list_tables() instead",
|
||||
"table_names() is deprecated, iterate list_tables() for all names "
|
||||
"or use table_exists([name]) to check existence",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
@@ -3590,7 +3632,7 @@ class AsyncConnection(object):
|
||||
"""Open a server-side job by id. See
|
||||
[DBConnection.open_job][lancedb.db.DBConnection.open_job].
|
||||
"""
|
||||
return AsyncJob(await self._inner.open_job(job_id))
|
||||
return _opened_job(await self._inner.open_job(job_id))
|
||||
|
||||
async def list_gpu_classes(self) -> List[GpuClass]:
|
||||
"""List configured Function GPU classes. See
|
||||
|
||||
@@ -44,6 +44,7 @@ from typing import (
|
||||
)
|
||||
|
||||
import pyarrow as pa
|
||||
from packaging.requirements import Requirement
|
||||
from pydantic import (
|
||||
AfterValidator,
|
||||
BaseModel,
|
||||
@@ -57,6 +58,7 @@ from pydantic import (
|
||||
from .schema import blob as _blob_field
|
||||
from .schema import is_blob_v2_field as _is_blob_v2_field
|
||||
from ._blob_reader import BlobReader
|
||||
from ._lancedb import _validate_conda_requirement
|
||||
from .secrets import EnvVarSecret
|
||||
|
||||
_Int32 = conint(strict=True, ge=-(2**31), le=2**31 - 1)
|
||||
@@ -493,6 +495,35 @@ class PythonRuntimeSpec(_RemoteValue):
|
||||
object.__setattr__(self, "gpu_class", None)
|
||||
return self
|
||||
|
||||
@property
|
||||
def digest(self) -> str:
|
||||
"""SHA-256 identity of the declared runtime, before building an image.
|
||||
|
||||
Covers Python version, environment sources, environment variables, and
|
||||
GPU settings. Package and system-package order is ignored; conda channel
|
||||
order is preserved. Compare with ``runtime_digest`` on
|
||||
[FunctionVersion][lancedb.functions.FunctionVersion].
|
||||
This identifies build inputs, not the resolved contents of unpinned
|
||||
dependencies or the deployment's default base image.
|
||||
"""
|
||||
if self.kind not in {"python", "python_v2"}:
|
||||
raise ValueError(f"cannot digest unknown runtime kind {self.kind!r}")
|
||||
value = self._known_dict()
|
||||
if not value.get("env"):
|
||||
value.pop("env", None)
|
||||
environment = value["environment"]
|
||||
for field in ("packages", "system_packages"):
|
||||
if field in environment:
|
||||
environment[field] = sorted(environment[field])
|
||||
encoded = json.dumps(
|
||||
value,
|
||||
ensure_ascii=False,
|
||||
allow_nan=False,
|
||||
sort_keys=True,
|
||||
separators=(",", ":"),
|
||||
).encode("utf-8")
|
||||
return f"sha256:{hashlib.sha256(encoded).hexdigest()}"
|
||||
|
||||
|
||||
class FunctionImage(_RemoteValue):
|
||||
"""A complete OCI Function image identified by its exact manifest digest."""
|
||||
@@ -534,8 +565,17 @@ class FunctionVersion(_RemoteValue):
|
||||
of the built ``image``. Compare it with
|
||||
``definition.registration_request.artifact.digest`` to check whether a local
|
||||
[FunctionDefinition][lancedb.functions.FunctionDefinition] has the same source.
|
||||
It does not cover dependencies, environment variables, Python version, or
|
||||
GPU settings. Equal source digests alone do not mean a version can be reused.
|
||||
It is ``None`` when the server does not provide a source digest.
|
||||
|
||||
``runtime_digest`` identifies the declared environment inputs. Compare it
|
||||
with ``definition.registration_request.runtime.digest`` to check whether
|
||||
the local runtime matches. It is ``None`` for images built before runtime
|
||||
identity was exposed. A missing digest cannot establish a match. Reusing a
|
||||
version also requires matching the source and all other registration inputs,
|
||||
including signature, Secret bindings, models, and execution controls.
|
||||
|
||||
``gpu_class`` is the operator-defined GPU pool fixed into this Function
|
||||
version, or ``None`` when registration used the deployment default.
|
||||
|
||||
@@ -552,6 +592,7 @@ class FunctionVersion(_RemoteValue):
|
||||
version: _ObjectVersion
|
||||
image: FunctionImage
|
||||
source_digest: Optional[str] = None
|
||||
runtime_digest: Optional[str] = None
|
||||
signature: FunctionSignature
|
||||
secret_bindings: tuple[SecretBinding, ...] = ()
|
||||
created_at_millis: int
|
||||
@@ -1296,6 +1337,21 @@ def _annotation_type(annotation: Any) -> tuple[pa.DataType, bool]:
|
||||
raise TypeError(f"unsupported Function annotation: {annotation!r}")
|
||||
|
||||
|
||||
def _validate_callable(function: Any) -> None:
|
||||
if hasattr(function, "__wrapped__"):
|
||||
raise TypeError(
|
||||
"decorated wrappers are not supported; put caching inside the function "
|
||||
"body or use a class Function with a cache in __init__"
|
||||
)
|
||||
if inspect.isgeneratorfunction(function) or inspect.isasyncgenfunction(function):
|
||||
raise TypeError(
|
||||
"generator Functions are not supported; return a value instead of "
|
||||
"yielding, or return a list for multiple values"
|
||||
)
|
||||
if inspect.isfunction(function) and function.__name__ == "<lambda>":
|
||||
raise TypeError("lambda Functions are not supported; use a named def instead")
|
||||
|
||||
|
||||
def _callable_parameters(function: Callable[..., Any]) -> tuple[inspect.Parameter, ...]:
|
||||
parameters = tuple(inspect.signature(function).parameters.values())
|
||||
for parameter in parameters:
|
||||
@@ -1306,7 +1362,11 @@ def _callable_parameters(function: Callable[..., Any]) -> tuple[inspect.Paramete
|
||||
):
|
||||
raise TypeError("Function callables require named, non-variadic parameters")
|
||||
if parameter.default is not inspect.Parameter.empty:
|
||||
raise TypeError("Function callable defaults are not supported")
|
||||
raise TypeError(
|
||||
f"Function callable defaults are not supported: {parameter.name!r}; "
|
||||
"move configuration parameters to a class Function's __init__ "
|
||||
"and pass them as binding-time initialization values"
|
||||
)
|
||||
return parameters
|
||||
|
||||
|
||||
@@ -1701,6 +1761,29 @@ def _packaged_by_source(value: Any) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def _validate_package_requirements(kind: str, packages: Sequence[str]) -> None:
|
||||
for index, package in enumerate(packages):
|
||||
field = f"{kind}[{index}]"
|
||||
if not isinstance(package, str):
|
||||
raise TypeError(f"{field} must be a string, got {package!r}")
|
||||
if not package or package != package.strip():
|
||||
raise ValueError(
|
||||
f"{field} requirement {package!r} must be non-empty and trimmed"
|
||||
)
|
||||
try:
|
||||
if kind == "conda":
|
||||
_validate_conda_requirement(package)
|
||||
else:
|
||||
candidate = package
|
||||
if re.match(r"^[A-Za-z][A-Za-z0-9+.-]*://", package):
|
||||
candidate = f"dependency @ {package}"
|
||||
Requirement(candidate)
|
||||
except ValueError as error:
|
||||
raise ValueError(
|
||||
f"invalid {field} requirement {package!r}: {error}"
|
||||
) from error
|
||||
|
||||
|
||||
def _requirement_name(requirement: str) -> str:
|
||||
requirement = requirement.rpartition("::")[2]
|
||||
match = _REQUIREMENT_NAME.match(requirement.strip())
|
||||
@@ -2176,6 +2259,7 @@ def _class_member(cls: type, name: str) -> Any:
|
||||
|
||||
def _class_call(cls: type) -> Callable[..., Any]:
|
||||
call = _class_member(cls, "__call__")
|
||||
_validate_callable(call)
|
||||
if not inspect.isfunction(call) or inspect.iscoroutinefunction(call):
|
||||
raise TypeError("a class Function must define a synchronous __call__ method")
|
||||
close = _class_member(cls, "close")
|
||||
@@ -2232,16 +2316,15 @@ class FunctionDefinition:
|
||||
if not is_class and (
|
||||
not inspect.isfunction(function) or inspect.iscoroutinefunction(function)
|
||||
):
|
||||
_validate_callable(function)
|
||||
raise TypeError(
|
||||
"@function requires a synchronous Python function or a class"
|
||||
)
|
||||
function_name = name or function.__name__
|
||||
if not _FUNCTION_NAME.fullmatch(function_name):
|
||||
raise ValueError(f"invalid Function name: {function_name!r}")
|
||||
if pip and conda:
|
||||
raise ValueError("a Function environment is pip or conda, not both")
|
||||
if conda_channels and not conda:
|
||||
raise ValueError("conda_channels requires conda packages")
|
||||
_validate_package_requirements("conda" if conda else "pip", conda or pip)
|
||||
gpu_marker = _normalize_gpu_marker(gpu)
|
||||
if gpu_class is not None:
|
||||
_validate_gpu_class_name(gpu_class)
|
||||
@@ -2298,6 +2381,11 @@ class FunctionDefinition:
|
||||
"model Functions reserve environment variables "
|
||||
f"{reserved!r}; the worker sets them for the private snapshot"
|
||||
)
|
||||
if not is_class:
|
||||
_validate_callable(function)
|
||||
function_name = name or function.__name__
|
||||
if not _FUNCTION_NAME.fullmatch(function_name):
|
||||
raise ValueError(f"invalid Function name: {function_name!r}")
|
||||
if is_class:
|
||||
if "<" in function.__qualname__ or "." in function.__qualname__:
|
||||
raise ValueError(
|
||||
@@ -2529,6 +2617,14 @@ def function(
|
||||
reuses them. An instance serves many batches of one binding, so state is
|
||||
shared across them, but not across instances or workers.
|
||||
|
||||
Functions and ``__call__`` methods must return a value. Generators,
|
||||
including async generators, are not supported; return a list to produce
|
||||
multiple values for a list output. Lambdas and decorated wrappers such as
|
||||
``functools.lru_cache`` are not supported. Use a named ``def`` and keep
|
||||
caches inside the body or in a class instance initialized by ``__init__``.
|
||||
Callable input parameters cannot have defaults; move configurable values
|
||||
to class initialization fields instead.
|
||||
|
||||
**Initialization.** The annotated parameters of a class's ``__init__``
|
||||
are the Function's initialization fields. Their values belong to each
|
||||
binding, not to the Function: ``function(text=col("body"), model="small")``
|
||||
@@ -2595,9 +2691,12 @@ def function(
|
||||
non-nullable. Required for batch annotations. When omitted, the output
|
||||
is inferred from the return annotation.
|
||||
pip : sequence of str, optional
|
||||
Pip requirements for the remote environment.
|
||||
Pip requirements for the remote environment. Syntax is validated at
|
||||
decoration time, including extras and environment markers. Named direct
|
||||
references and bare package or git URLs are supported.
|
||||
conda : sequence of str, optional
|
||||
Conda packages for the remote environment, instead of ``pip``.
|
||||
Conda packages for the remote environment, instead of ``pip``. MatchSpec
|
||||
syntax is validated at decoration time, including channels and builds.
|
||||
conda_channels : sequence of str, optional
|
||||
Conda channels in priority order; requires ``conda``.
|
||||
apt : sequence of str, optional
|
||||
|
||||
@@ -17,6 +17,7 @@ from lancedb.background_loop import LOOP
|
||||
|
||||
from . import _lancedb
|
||||
from ._lancedb import JobDescription, JobFailureInfo, JobInfo, _append_doc_url
|
||||
from .functions import RefreshColumnResult
|
||||
from .remote.errors import HttpError, RetryError
|
||||
|
||||
T = TypeVar("T")
|
||||
@@ -692,3 +693,9 @@ def _typed_job(
|
||||
) -> AsyncJob[T]:
|
||||
"""Bind an internal JSON-producing job to its public result model."""
|
||||
return AsyncJob(inner, result_decoder)
|
||||
|
||||
|
||||
def _opened_job(inner: "_lancedb.Job") -> AsyncJob:
|
||||
if inner.job_type in ("function_refresh", "computed_refresh", "refresh_column"):
|
||||
return _typed_job(inner, RefreshColumnResult.from_json)
|
||||
return AsyncJob(inner)
|
||||
|
||||
@@ -175,6 +175,9 @@ class _AsyncPagedNameListing(AsyncIterator[str]):
|
||||
class AsyncTableListing(_AsyncPagedNameListing):
|
||||
"""Awaitable table iterator; awaiting loads one page.
|
||||
|
||||
Iteration fetches all pages. The ``tables`` attribute contains only the
|
||||
current page, so use ``await db.table_exists([name])`` for existence checks.
|
||||
|
||||
For example::
|
||||
|
||||
page = await db.list_tables(limit=20)
|
||||
@@ -229,6 +232,10 @@ class _PagedNameListing(Iterator[str]):
|
||||
class TableListing(_PagedNameListing):
|
||||
"""Table iterator retaining the current page as a list.
|
||||
|
||||
Iteration fetches all pages. The ``tables`` attribute contains only the
|
||||
current page, so use ``db.table_exists([name])`` or ``name in db`` for
|
||||
existence checks. Use ``list(db.list_tables())`` to collect all names.
|
||||
|
||||
For example::
|
||||
|
||||
page = db.list_tables(limit=20)
|
||||
@@ -239,6 +246,7 @@ class TableListing(_PagedNameListing):
|
||||
|
||||
@property
|
||||
def tables(self) -> list[str]:
|
||||
"""A copy of the table names in the most recently fetched page."""
|
||||
return self._inner.tables
|
||||
|
||||
|
||||
|
||||
@@ -579,12 +579,15 @@ class LanceNamespaceDBConnection(DBConnection):
|
||||
If limit is None, return all table names; zero returns an empty list.
|
||||
|
||||
.. deprecated::
|
||||
Use :meth:`list_tables` instead, which provides proper pagination support.
|
||||
Iterate over :meth:`list_tables` to get all names, or use
|
||||
:meth:`table_exists` to check for a particular table. The listing's
|
||||
``tables`` attribute contains only one page.
|
||||
"""
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"table_names() is deprecated, use list_tables() instead",
|
||||
"table_names() is deprecated, iterate list_tables() for all names "
|
||||
"or use table_exists([name]) to check existence",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
@@ -1015,6 +1018,8 @@ class LanceNamespaceDBConnection(DBConnection):
|
||||
bool
|
||||
True if the table exists, False otherwise.
|
||||
"""
|
||||
if self._route_pushdown_to_rust:
|
||||
return LOOP.run(self._inner.table_exists(table_id))
|
||||
request = TableExistsRequest(id=table_id)
|
||||
try:
|
||||
self._namespace_client.table_exists(request)
|
||||
@@ -1030,7 +1035,11 @@ class LanceNamespaceDBConnection(DBConnection):
|
||||
limit: Optional[int] = None,
|
||||
) -> TableListing:
|
||||
"""
|
||||
List all tables in this database with pagination support.
|
||||
Iterate over all tables in this database, fetching pages as needed.
|
||||
|
||||
The ``tables`` attribute contains only the current page (100 names by
|
||||
default). Iterate over the listing to visit all pages, or use
|
||||
``table_exists([name])`` to check for a particular table.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -1227,12 +1236,15 @@ class AsyncLanceNamespaceDBConnection:
|
||||
If limit is None, return all table names; zero returns an empty list.
|
||||
|
||||
.. deprecated::
|
||||
Use :meth:`list_tables` instead, which provides proper pagination support.
|
||||
Iterate over :meth:`list_tables` to get all names, or use
|
||||
:meth:`table_exists` to check for a particular table. The listing's
|
||||
``tables`` attribute contains only one page.
|
||||
"""
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"table_names() is deprecated, use list_tables() instead",
|
||||
"table_names() is deprecated, iterate list_tables() for all names "
|
||||
"or use table_exists([name]) to check existence",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
@@ -1614,6 +1626,8 @@ class AsyncLanceNamespaceDBConnection:
|
||||
bool
|
||||
True if the table exists, False otherwise.
|
||||
"""
|
||||
if self._route_pushdown_to_rust:
|
||||
return await self._inner.table_exists(table_id)
|
||||
request = TableExistsRequest(id=table_id)
|
||||
try:
|
||||
self._namespace_client.table_exists(request)
|
||||
@@ -1628,7 +1642,11 @@ class AsyncLanceNamespaceDBConnection:
|
||||
limit: Optional[int] = None,
|
||||
) -> AsyncTableListing:
|
||||
"""
|
||||
List all tables in this database with pagination support.
|
||||
Iterate over all tables in this database, fetching pages as needed.
|
||||
|
||||
The ``tables`` attribute contains only the current page (100 names by
|
||||
default). Iterate over the listing to visit all pages, or use
|
||||
``table_exists([name])`` to check for a particular table.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
@@ -214,6 +214,7 @@ class RemoteDBConnection(DBConnection):
|
||||
client_config,
|
||||
oauth_config,
|
||||
sql_host_override,
|
||||
storage_options,
|
||||
):
|
||||
config = (
|
||||
ClientConfig(**client_config)
|
||||
@@ -233,7 +234,7 @@ class RemoteDBConnection(DBConnection):
|
||||
result.region = "us-east-1"
|
||||
result.host_override = endpoint
|
||||
result.sql_host_override = sql_host_override
|
||||
result.storage_options = None
|
||||
result.storage_options = storage_options
|
||||
result.client_config = replace(config, extra_headers=headers)
|
||||
result._catalog_oauth = oauth_config is not None
|
||||
result._conn = inner
|
||||
@@ -430,7 +431,11 @@ class RemoteDBConnection(DBConnection):
|
||||
page_token: Optional[str] = None,
|
||||
limit: Optional[int] = None,
|
||||
) -> TableListing:
|
||||
"""List a page of tables in this database.
|
||||
"""Iterate over all tables in this database, fetching pages as needed.
|
||||
|
||||
The ``tables`` attribute contains only the current page (100 names by
|
||||
default). Iterate over the listing to visit all pages, or use
|
||||
``table_exists([name])`` to check for a particular table.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -468,7 +473,9 @@ class RemoteDBConnection(DBConnection):
|
||||
"""List the names of all tables in the database.
|
||||
|
||||
.. deprecated::
|
||||
Use :meth:`list_tables` instead, which provides proper pagination support.
|
||||
Iterate over :meth:`list_tables` to get all names, or use
|
||||
:meth:`table_exists` to check for a particular table. The listing's
|
||||
``tables`` attribute contains only one page.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -488,7 +495,8 @@ class RemoteDBConnection(DBConnection):
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"table_names() is deprecated, use list_tables() instead",
|
||||
"table_names() is deprecated, iterate list_tables() for all names "
|
||||
"or use table_exists([name]) to check existence",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from datetime import timedelta
|
||||
import json
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -62,6 +64,7 @@ def test_catalog_sync_scope_and_serialization(catalog_server):
|
||||
endpoint,
|
||||
api_key="secret",
|
||||
sql_host_override="invalid://localhost",
|
||||
storage_options={"azure_storage_account_name": "catalog-account"},
|
||||
client_config={
|
||||
"extra_headers": {
|
||||
"X-LanceDB-Database": "wrong",
|
||||
@@ -80,6 +83,7 @@ def test_catalog_sync_scope_and_serialization(catalog_server):
|
||||
assert db.table_names() == []
|
||||
restored = lancedb.deserialize_conn(db.serialize())
|
||||
assert restored.sql_host_override == "invalid://localhost"
|
||||
assert restored.storage_options == {"azure_storage_account_name": "catalog-account"}
|
||||
for connection in (db, restored):
|
||||
with pytest.raises(ValueError, match="sql_host_override must use"):
|
||||
connection.execute_query_async("SELECT 1")
|
||||
@@ -98,6 +102,7 @@ def test_catalog_sync_scope_and_serialization(catalog_server):
|
||||
)
|
||||
assert "x-lancedb-database-prefix" not in headers
|
||||
assert headers["x-api-key"] == "secret"
|
||||
assert headers["x-azure-storage-account-name"] == "catalog-account"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -114,7 +119,9 @@ async def test_catalog_async_and_errors(catalog_server):
|
||||
]
|
||||
)
|
||||
catalog = await lancedb.connect_catalog_async(
|
||||
endpoint, sql_host_override="invalid://localhost"
|
||||
endpoint,
|
||||
sql_host_override="invalid://localhost",
|
||||
storage_options={"account_name": "async-account"},
|
||||
)
|
||||
assert isinstance(catalog, lancedb.AsyncCatalog)
|
||||
db = await catalog.connect_database("analytics")
|
||||
@@ -130,6 +137,9 @@ async def test_catalog_async_and_errors(catalog_server):
|
||||
await catalog.drop_database("full")
|
||||
await catalog.drop_database("missing", ignore_missing=True)
|
||||
assert requests[4][2] == {"mode": "Fail", "behavior": "Restrict"}
|
||||
for _, headers, _ in requests:
|
||||
headers = {key.lower(): value for key, value in headers.items()}
|
||||
assert headers["x-azure-storage-account-name"] == "async-account"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("endpoint", ["/tmp/catalog", "s3://bucket", "db://db"])
|
||||
@@ -138,6 +148,170 @@ def test_catalog_requires_remote_endpoint(endpoint):
|
||||
lancedb.connect_catalog(endpoint)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("asynchronous", [False, True])
|
||||
@pytest.mark.parametrize("region", ["us-east-1", "not-a-region"])
|
||||
@pytest.mark.asyncio
|
||||
async def test_catalog_accepts_database_connection_settings(
|
||||
catalog_server, asynchronous, region
|
||||
):
|
||||
endpoint, requests, responses = catalog_server
|
||||
responses.extend([(200, {"namespaces": []}), (200, {"tables": []})])
|
||||
settings = {
|
||||
"uri": "db://analytics",
|
||||
"api_key": "shared-secret",
|
||||
"region": region,
|
||||
"host_override": endpoint,
|
||||
"sql_host_override": "invalid://localhost",
|
||||
"read_consistency_interval": timedelta(seconds=5),
|
||||
"client_config": {"extra_headers": {"x-shared-setting": "shared"}},
|
||||
"storage_options": {"azure_storage_account_name": "shared-account"},
|
||||
"session": None,
|
||||
"manifest_enabled": False,
|
||||
"namespace_client_properties": None,
|
||||
}
|
||||
if not asynchronous:
|
||||
settings.update(
|
||||
request_thread_pool=None,
|
||||
namespace_client_impl=None,
|
||||
namespace_client_pushdown_operations=None,
|
||||
)
|
||||
with pytest.warns(
|
||||
UserWarning, match="region is ignored by connect_catalog"
|
||||
) as caught:
|
||||
catalog = (
|
||||
await lancedb.connect_catalog_async(**settings)
|
||||
if asynchronous
|
||||
else lancedb.connect_catalog(**settings)
|
||||
)
|
||||
assert len(caught) == 1
|
||||
assert catalog.uri == endpoint
|
||||
assert (
|
||||
[name async for name in catalog.list_databases()]
|
||||
if asynchronous
|
||||
else list(catalog.list_databases())
|
||||
) == []
|
||||
db = (
|
||||
await lancedb.connect_async(**settings)
|
||||
if asynchronous
|
||||
else lancedb.connect(**settings)
|
||||
)
|
||||
assert (await db.table_names() if asynchronous else db.table_names()) == []
|
||||
root_headers = {key.lower(): value for key, value in requests[0][1].items()}
|
||||
db_headers = {key.lower(): value for key, value in requests[1][1].items()}
|
||||
for headers in (root_headers, db_headers):
|
||||
assert headers["x-api-key"] == "shared-secret"
|
||||
assert headers["x-shared-setting"] == "shared"
|
||||
assert headers["x-azure-storage-account-name"] == "shared-account"
|
||||
assert "x-lancedb-database" not in root_headers
|
||||
assert db_headers["x-lancedb-database"] == "analytics"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("asynchronous", [False, True])
|
||||
@pytest.mark.parametrize("host_only", [False, True])
|
||||
@pytest.mark.asyncio
|
||||
async def test_catalog_default_region_is_silent_and_api_key_uses_environment(
|
||||
catalog_server, monkeypatch, asynchronous, host_only
|
||||
):
|
||||
endpoint, requests, responses = catalog_server
|
||||
monkeypatch.setenv("LANCEDB_API_KEY", "environment-secret")
|
||||
responses.extend([(200, {}), (200, {"tables": []})])
|
||||
settings = {"host_override": endpoint} if host_only else {"uri": endpoint}
|
||||
with warnings.catch_warnings(record=True) as caught:
|
||||
warnings.simplefilter("always")
|
||||
catalog = (
|
||||
await lancedb.connect_catalog_async(**settings)
|
||||
if asynchronous
|
||||
else lancedb.connect_catalog(**settings)
|
||||
)
|
||||
assert caught == []
|
||||
assert catalog.uri == endpoint
|
||||
db = (
|
||||
await catalog.connect_database("analytics")
|
||||
if asynchronous
|
||||
else catalog.connect_database("analytics")
|
||||
)
|
||||
if not asynchronous:
|
||||
db = lancedb.deserialize_conn(db.serialize())
|
||||
assert (await db.table_names() if asynchronous else db.table_names()) == []
|
||||
for _, headers, _ in requests:
|
||||
headers = {key.lower(): value for key, value in headers.items()}
|
||||
assert headers["x-api-key"] == "environment-secret"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("asynchronous", [False, True])
|
||||
@pytest.mark.asyncio
|
||||
async def test_catalog_host_override_selects_endpoint(catalog_server, asynchronous):
|
||||
endpoint, _, _ = catalog_server
|
||||
settings = {"uri": "https://unused.example", "host_override": endpoint}
|
||||
catalog = (
|
||||
await lancedb.connect_catalog_async(**settings)
|
||||
if asynchronous
|
||||
else lancedb.connect_catalog(**settings)
|
||||
)
|
||||
assert catalog.uri == endpoint
|
||||
|
||||
|
||||
@pytest.mark.parametrize("asynchronous", [False, True])
|
||||
@pytest.mark.parametrize(
|
||||
"options, message",
|
||||
[
|
||||
({}, "uri or host_override is required"),
|
||||
({"session": object()}, "session"),
|
||||
({"manifest_enabled": True}, "manifest_enabled"),
|
||||
({"namespace_client_properties": {}}, "namespace_client_properties"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_catalog_rejects_unsupported_connection_settings(
|
||||
catalog_server, asynchronous, options, message
|
||||
):
|
||||
_, requests, _ = catalog_server
|
||||
error = NotImplementedError if options else ValueError
|
||||
with pytest.raises(error, match=message):
|
||||
if asynchronous:
|
||||
await lancedb.connect_catalog_async(**options)
|
||||
else:
|
||||
lancedb.connect_catalog(**options)
|
||||
assert requests == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"options, error, message",
|
||||
[
|
||||
(
|
||||
{"namespace_client_impl": "dir"},
|
||||
NotImplementedError,
|
||||
"namespace_client_impl",
|
||||
),
|
||||
(
|
||||
{"namespace_client_pushdown_operations": []},
|
||||
NotImplementedError,
|
||||
"namespace_client_pushdown_operations",
|
||||
),
|
||||
({"unknown_option": True}, ValueError, "Unknown keyword arguments"),
|
||||
],
|
||||
)
|
||||
def test_catalog_rejects_unsupported_sync_settings(options, error, message):
|
||||
with pytest.raises(error, match=message):
|
||||
lancedb.connect_catalog(**options)
|
||||
|
||||
|
||||
def test_catalog_accepts_deprecated_sync_settings(catalog_server):
|
||||
endpoint, _, responses = catalog_server
|
||||
responses.append((200, {}))
|
||||
with pytest.warns(DeprecationWarning) as caught:
|
||||
catalog = lancedb.connect_catalog(
|
||||
endpoint,
|
||||
request_thread_pool=2,
|
||||
connection_timeout=5,
|
||||
read_timeout=10,
|
||||
)
|
||||
assert len(caught) == 3
|
||||
db = catalog.connect_database("analytics")
|
||||
assert db.client_config.timeout_config.connect_timeout == timedelta(seconds=5)
|
||||
assert db.client_config.timeout_config.read_timeout == timedelta(seconds=10)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("asynchronous", [False, True])
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("page_token,page_limit", [(None, None), ("start/token", 2)])
|
||||
|
||||
@@ -282,9 +282,7 @@ async def test_table_listing_defaults_and_zero_limit(tmp_path):
|
||||
assert empty.page_token is None
|
||||
|
||||
|
||||
def test_db_contains_stops_after_matching_table_page(
|
||||
tmp_db: lancedb.DBConnection, monkeypatch
|
||||
):
|
||||
def test_db_len_includes_all_table_pages(tmp_db: lancedb.DBConnection, monkeypatch):
|
||||
calls = []
|
||||
pages = {
|
||||
None: SimpleNamespace(tables=["table_0", "table_1"], page_token="next"),
|
||||
@@ -297,18 +295,44 @@ def test_db_contains_stops_after_matching_table_page(
|
||||
|
||||
monkeypatch.setattr(tmp_db, "list_tables", list_tables)
|
||||
|
||||
assert "table_1" in tmp_db
|
||||
assert calls == [None]
|
||||
|
||||
calls.clear()
|
||||
assert "table_2" in tmp_db
|
||||
assert calls == [None, "next"]
|
||||
|
||||
calls.clear()
|
||||
assert len(tmp_db) == 3
|
||||
assert calls == [None, "next"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("namespace_path", [[], ["analytics", "nested"]])
|
||||
async def test_local_table_exists_without_listing(
|
||||
tmp_path, monkeypatch, namespace_path
|
||||
):
|
||||
db = lancedb.connect(tmp_path)
|
||||
for depth in range(1, len(namespace_path) + 1):
|
||||
db.create_namespace(namespace_path[:depth])
|
||||
db.create_table("events", data=[{"id": 1}], namespace_path=namespace_path)
|
||||
if not namespace_path:
|
||||
for idx in range(100):
|
||||
(tmp_path / f"a{idx:03}.lance").mkdir()
|
||||
assert "events" not in db.list_tables().tables
|
||||
adb = await lancedb.connect_async(tmp_path)
|
||||
|
||||
def fail_listing(*args, **kwargs):
|
||||
raise AssertionError("Existence checks must not list tables")
|
||||
|
||||
monkeypatch.setattr(db, "list_tables", fail_listing)
|
||||
monkeypatch.setattr(adb, "list_tables", fail_listing)
|
||||
table_id = namespace_path + ["events"]
|
||||
assert db.table_exists(table_id) is True
|
||||
assert await adb.table_exists(table_id) is True
|
||||
assert db.table_exists(namespace_path + ["missing"]) is False
|
||||
assert await adb.table_exists(namespace_path + ["missing"]) is False
|
||||
assert ("events" in db) is (not namespace_path)
|
||||
assert "missing" not in db
|
||||
assert table_id == namespace_path + ["events"]
|
||||
|
||||
db.drop_table("events", namespace_path=namespace_path)
|
||||
assert db.table_exists(table_id) is False
|
||||
assert await adb.table_exists(table_id) is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_table_names_async(tmp_path):
|
||||
db = lancedb.connect(tmp_path)
|
||||
|
||||
@@ -34,7 +34,7 @@ FIXTURES = (
|
||||
|
||||
|
||||
def fixture(name: str) -> str:
|
||||
return (FIXTURES / name).read_text()
|
||||
return (FIXTURES / name).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def job_result(name: str) -> dict:
|
||||
@@ -148,6 +148,38 @@ def test_function_version_identity_is_immutable_and_exact():
|
||||
FunctionVersion(**{**value, "version": invalid})
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"case", json.loads(fixture("runtime_identity.json")), ids=lambda case: case["name"]
|
||||
)
|
||||
def test_runtime_digests_match_server_golden_values(case):
|
||||
runtime = PythonRuntimeSpec.from_json(json.dumps(case["runtime"]))
|
||||
assert runtime.digest == case["digest"]
|
||||
assert (
|
||||
PythonRuntimeSpec.from_json(runtime.to_canonical_json()).digest
|
||||
== runtime.digest
|
||||
)
|
||||
|
||||
|
||||
def test_unknown_runtime_digest_fails_closed():
|
||||
runtime = PythonRuntimeSpec.from_json('{"kind":"python_v3","future":"value"}')
|
||||
with pytest.raises(ValueError, match="cannot digest unknown runtime kind"):
|
||||
runtime.digest
|
||||
|
||||
|
||||
@pytest.mark.parametrize("runtime_digest", [None, "sha256:runtime-inputs"])
|
||||
def test_function_version_preserves_runtime_digest(runtime_digest):
|
||||
value = job_result("remote_function_job.json")
|
||||
legacy = FunctionVersion.from_json(json.dumps(value))
|
||||
assert legacy.runtime_digest is None
|
||||
assert "runtime_digest" not in json.loads(legacy.to_canonical_json())
|
||||
value["runtime_digest"] = runtime_digest
|
||||
version = FunctionVersion.from_json(json.dumps(value))
|
||||
assert version.runtime_digest == runtime_digest
|
||||
assert FunctionVersion.from_json(version.to_canonical_json()) == version
|
||||
with pytest.raises((TypeError, ValueError)):
|
||||
version.runtime_digest = "sha256:changed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source_digest", [None, "sha256:source-artifact"])
|
||||
def test_function_version_preserves_source_digest(source_digest):
|
||||
value = job_result("remote_function_job.json")
|
||||
|
||||
@@ -1891,6 +1891,29 @@ def test_annotation_and_explicit_schema_validation_fail_closed():
|
||||
return value
|
||||
|
||||
|
||||
def test_default_function_runtime_matches_server_identity():
|
||||
definition = function(python_version="3.12")(analyze_caption.__wrapped__)
|
||||
runtime = definition.registration_request.runtime
|
||||
assert runtime.env == {}
|
||||
cases = json.loads((FIXTURES / "runtime_identity.json").read_text(encoding="utf-8"))
|
||||
expected = next(
|
||||
case["digest"] for case in cases if case["name"] == "empty-environment"
|
||||
)
|
||||
assert runtime.digest == expected
|
||||
|
||||
|
||||
def test_environment_changes_do_not_change_source_identity():
|
||||
definition = function(
|
||||
pip=["openai==3.46.0"],
|
||||
env={"MODE": "test"},
|
||||
python_version="3.12",
|
||||
)(analyze_caption.__wrapped__)
|
||||
previous = analyze_caption.registration_request
|
||||
changed = definition.registration_request
|
||||
assert previous.artifact.digest == changed.artifact.digest
|
||||
assert previous.runtime.digest != changed.runtime.digest
|
||||
|
||||
|
||||
def test_local_function_catalog_operations_are_not_supported(tmp_path):
|
||||
db = lancedb.connect(tmp_path)
|
||||
message = "Function catalog operations are not supported by this database"
|
||||
@@ -1950,6 +1973,7 @@ async def test_async_catalog_path_preserves_execution_controls():
|
||||
(FIXTURES / "remote_function_version.canonical.json").read_text()
|
||||
)
|
||||
definition.update(
|
||||
runtime_digest=normalize_score.registration_request.runtime.digest,
|
||||
batch_size=12,
|
||||
row_timeout_seconds=8.0,
|
||||
result_stability="input_and_context",
|
||||
@@ -1977,6 +2001,7 @@ def test_sync_catalog_path_preserves_execution_controls():
|
||||
(FIXTURES / "remote_function_version.canonical.json").read_text()
|
||||
)
|
||||
definition.update(
|
||||
runtime_digest=normalize_score.registration_request.runtime.digest,
|
||||
batch_size=12,
|
||||
row_timeout_seconds=8.0,
|
||||
result_stability="input_and_context",
|
||||
@@ -2090,6 +2115,9 @@ def _mock_remote_function_catalog():
|
||||
)["image"],
|
||||
"signature": body["signature"],
|
||||
"source_digest": body["artifact"]["digest"],
|
||||
"runtime_digest": PythonRuntimeSpec.from_json(
|
||||
json.dumps(body["runtime"])
|
||||
).digest,
|
||||
"secret_bindings": body.get("secret_bindings", []),
|
||||
"created_at_millis": 1787270400000, # 2026-08-21T00:00:00Z
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import pyarrow as pa
|
||||
import pytest
|
||||
|
||||
from lancedb import col
|
||||
from lancedb.functions import FunctionDefinition, FunctionVersion, function
|
||||
from lancedb.functions import FunctionDefinition, FunctionVersion, function, udf
|
||||
|
||||
FIXTURES = (
|
||||
Path(__file__).parents[3]
|
||||
@@ -127,6 +127,108 @@ def test_function_without_initialization_keeps_its_wire_form():
|
||||
assert request["artifact"]["kind"] == "python_callable"
|
||||
|
||||
|
||||
@pytest.mark.filterwarnings("ignore:lancedb.udf is deprecated:DeprecationWarning")
|
||||
@pytest.mark.parametrize("decorator", [function, udf])
|
||||
@pytest.mark.parametrize("explicit_schemas", [False, True])
|
||||
@pytest.mark.parametrize("class_function", [False, True])
|
||||
@pytest.mark.parametrize(
|
||||
("declaration", "statement"),
|
||||
[
|
||||
("def", "yield value"),
|
||||
("def", "yield from [value]"),
|
||||
("async def", "yield value"),
|
||||
],
|
||||
)
|
||||
def test_generator_functions_are_rejected_at_decoration(
|
||||
helper_package, decorator, explicit_schemas, class_function, declaration, statement
|
||||
):
|
||||
signature = (
|
||||
"__call__(self, value: int)" if class_function else "generates(value: int)"
|
||||
)
|
||||
source = f"{declaration} {signature} -> int:\n {statement}\n"
|
||||
if class_function:
|
||||
source = "class generates:\n" + textwrap.indent(source, " ")
|
||||
module = helper_package("fx_generator", {"__init__.py": source})
|
||||
options = (
|
||||
{
|
||||
"input_schema": pa.schema([pa.field("value", pa.int64(), nullable=False)]),
|
||||
"output_schema": pa.int64(),
|
||||
}
|
||||
if explicit_schemas
|
||||
else {}
|
||||
)
|
||||
with pytest.raises(TypeError) as error:
|
||||
decorator(**options)(module.generates)
|
||||
message = str(error.value)
|
||||
assert "generator Functions are not supported" in message
|
||||
assert "return a value" in message
|
||||
assert "return a list" in message
|
||||
|
||||
|
||||
@pytest.mark.filterwarnings("ignore:lancedb.udf is deprecated:DeprecationWarning")
|
||||
@pytest.mark.parametrize("decorator", [function, udf])
|
||||
@pytest.mark.parametrize("explicit_name", [False, True])
|
||||
def test_lambda_functions_explain_the_named_alternative(decorator, explicit_name):
|
||||
options = {"name": "double"} if explicit_name else {}
|
||||
with pytest.raises(TypeError, match="lambda.*use a named def"):
|
||||
decorator(**options)(lambda value: value * 2)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("class_function", [False, True])
|
||||
@pytest.mark.parametrize("cache_decorator", ["lru_cache", "cache"])
|
||||
def test_cached_functions_explain_where_to_keep_caches(
|
||||
helper_package, class_function, cache_decorator
|
||||
):
|
||||
signature = "__call__(self, value: int)" if class_function else "cached(value: int)"
|
||||
source = (
|
||||
f"@functools.{cache_decorator}\ndef {signature} -> int:\n return value * 2\n"
|
||||
)
|
||||
if class_function:
|
||||
source = "class cached:\n" + textwrap.indent(source, " ")
|
||||
module = helper_package("fx_cached", {"__init__.py": "import functools\n" + source})
|
||||
with pytest.raises(TypeError) as error:
|
||||
function(module.cached)
|
||||
message = str(error.value)
|
||||
assert "decorated wrappers are not supported" in message
|
||||
assert "inside the function body" in message
|
||||
assert "class Function with a cache in __init__" in message
|
||||
|
||||
|
||||
@pytest.mark.parametrize("class_function", [False, True])
|
||||
@pytest.mark.parametrize("keyword_only", [False, True])
|
||||
def test_callable_defaults_explain_class_initialization(
|
||||
helper_package, class_function, keyword_only
|
||||
):
|
||||
parameters = "value: float, " + ("*, " if keyword_only else "")
|
||||
parameters += "threshold: float = 0.5"
|
||||
signature = (
|
||||
f"__call__(self, {parameters})"
|
||||
if class_function
|
||||
else f"thresholded({parameters})"
|
||||
)
|
||||
source = f"def {signature} -> bool:\n return value >= threshold\n"
|
||||
if class_function:
|
||||
source = "class thresholded:\n" + textwrap.indent(source, " ")
|
||||
module = helper_package("fx_defaults", {"__init__.py": source})
|
||||
with pytest.raises(TypeError) as error:
|
||||
function(module.thresholded)
|
||||
message = str(error.value)
|
||||
assert "defaults are not supported: 'threshold'" in message
|
||||
assert "class Function's __init__" in message
|
||||
assert "binding-time initialization values" in message
|
||||
|
||||
|
||||
def test_function_can_return_a_list_from_a_generator_expression():
|
||||
@function
|
||||
def many(value: int) -> list[int]:
|
||||
return list(item * 2 for item in range(value))
|
||||
|
||||
namespace = {}
|
||||
exec(compile(artifact(many), "user_function.py", "exec"), namespace)
|
||||
assert namespace["many"](3) == [0, 2, 4]
|
||||
assert many.registration_request.signature.output.arrow_type == "list<int64>"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", ["function", "class"])
|
||||
@pytest.mark.parametrize(
|
||||
("global_value", "value_type"),
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
import pytest
|
||||
|
||||
from lancedb import function, udf
|
||||
from lancedb.functions import FunctionDefinition
|
||||
|
||||
|
||||
def identity(value: int) -> int:
|
||||
return value
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"package",
|
||||
[
|
||||
"torch>=2.0,,<3",
|
||||
"torch>=",
|
||||
"torch=>2.0",
|
||||
"torch[",
|
||||
"torch; python_version >=",
|
||||
"",
|
||||
" torch",
|
||||
"torch ",
|
||||
],
|
||||
)
|
||||
def test_invalid_pip_requirement_fails_before_packaging(package, monkeypatch):
|
||||
def unexpected_packaging(*args, **kwargs):
|
||||
pytest.fail("invalid requirements must fail before packaging the function")
|
||||
|
||||
monkeypatch.setattr("lancedb.functions._infer_signature", unexpected_packaging)
|
||||
with pytest.raises(ValueError) as error:
|
||||
function(pip=["numpy", package])(identity)
|
||||
assert "pip[1]" in str(error.value)
|
||||
assert repr(package) in str(error.value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"package",
|
||||
[
|
||||
"numpy>=1,,<3",
|
||||
"numpy>=",
|
||||
"numpy[version=]",
|
||||
"numpy[unknown_field=value]",
|
||||
"",
|
||||
" numpy",
|
||||
"numpy ",
|
||||
],
|
||||
)
|
||||
def test_invalid_conda_requirement_names_entry(package):
|
||||
with pytest.raises(ValueError) as error:
|
||||
function(conda=["scipy", package])(identity)
|
||||
assert "conda[1]" in str(error.value)
|
||||
assert repr(package) in str(error.value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", ["pip", "conda"])
|
||||
@pytest.mark.parametrize("package", [None, 42, ["numpy"]])
|
||||
def test_requirement_must_be_a_string(kind, package):
|
||||
with pytest.raises(TypeError, match=rf"{kind}\[1\] must be a string"):
|
||||
function(**{kind: ["numpy", package]})(identity)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"package",
|
||||
[
|
||||
"numpy",
|
||||
"torch>=2.0,<3",
|
||||
'requests[security,socks]>=2; python_version >= "3.10"',
|
||||
"numpy (>=1.26, <3)",
|
||||
"six @ https://example.com/six-1.16.0.tar.gz",
|
||||
"six @ git+https://github.com/benjaminp/six.git@main",
|
||||
"https://example.com/six-1.16.0.tar.gz",
|
||||
"git+https://github.com/benjaminp/six.git@main",
|
||||
"git+ssh://git@github.com/benjaminp/six.git@main",
|
||||
],
|
||||
)
|
||||
def test_supported_pip_requirements_are_preserved(package):
|
||||
definition = function(pip=[package])(identity)
|
||||
assert definition.registration_request.runtime.environment.packages == (package,)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"package",
|
||||
[
|
||||
"numpy",
|
||||
"numpy=1.26",
|
||||
"numpy>=1.26,<3",
|
||||
"numpy=1.26=py310_0",
|
||||
"numpy 1.26 py310_0",
|
||||
"conda-forge::numpy>=1.26",
|
||||
"conda-forge/linux-64::numpy>=1.26",
|
||||
"numpy[version='>=1.26,<3',build='py310*']",
|
||||
],
|
||||
)
|
||||
def test_supported_conda_requirements_are_preserved(package):
|
||||
definition = function(conda=[package])(identity)
|
||||
assert definition.registration_request.runtime.environment.packages == (package,)
|
||||
|
||||
|
||||
def test_requirements_still_sort_and_deduplicate():
|
||||
definition = function(pip=["torch>=2", "numpy", "torch>=2"])(identity)
|
||||
assert definition.registration_request.runtime.environment.packages == (
|
||||
"numpy",
|
||||
"torch>=2",
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_udf_alias_validates_requirements():
|
||||
with pytest.warns(DeprecationWarning, match="use lancedb.function"):
|
||||
with pytest.raises(ValueError, match=r"pip\[0\]"):
|
||||
udf(pip=["torch>=2.0,,<3"])(identity)
|
||||
|
||||
|
||||
def test_direct_function_definition_validates_requirements():
|
||||
with pytest.raises(ValueError, match=r"pip\[0\]"):
|
||||
FunctionDefinition(
|
||||
identity,
|
||||
name=None,
|
||||
input_schema=None,
|
||||
output_schema=None,
|
||||
pip=("torch>=2.0,,<3",),
|
||||
env={},
|
||||
python_version=None,
|
||||
)
|
||||
@@ -34,6 +34,27 @@ PUSHDOWN_DATA = pa.table(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("table_id", [["events"], ["analytics", "events"], ["missing"]])
|
||||
async def test_custom_namespace_table_exists_uses_namespace_api(table_id):
|
||||
class ExistenceNamespace(LanceNamespace):
|
||||
def namespace_id(self):
|
||||
return "existence-test"
|
||||
|
||||
def table_exists(self, request):
|
||||
if request.id == ["missing"]:
|
||||
raise TableNotFoundError("Table not found")
|
||||
|
||||
def describe_table(self, request):
|
||||
raise AssertionError("Custom existence checks must not open tables")
|
||||
|
||||
namespace = ExistenceNamespace()
|
||||
db = LanceNamespaceDBConnection(namespace)
|
||||
adb = lancedb.AsyncLanceNamespaceDBConnection(namespace)
|
||||
assert db.table_exists(table_id) is (table_id != ["missing"])
|
||||
assert await adb.table_exists(table_id) is (table_id != ["missing"])
|
||||
|
||||
|
||||
class TestNamespaceCreateTableOptions:
|
||||
@pytest.mark.parametrize("version", ["legacy", "stable"])
|
||||
@pytest.mark.parametrize("empty", [False, True])
|
||||
@@ -411,8 +432,16 @@ class TestNamespaceConnection:
|
||||
assert "test_ns" in db.list_namespaces().namespaces
|
||||
|
||||
schema = pa.schema([pa.field("id", pa.int64())])
|
||||
db.create_table("root_table", schema=schema)
|
||||
assert db.table_exists(["root_table"]) is True
|
||||
assert "root_table" in db
|
||||
assert db.table_exists(["missing"]) is False
|
||||
assert "missing" not in db
|
||||
table = db.create_table("test_table", schema=schema, namespace_path=["test_ns"])
|
||||
assert table.namespace == ["test_ns"]
|
||||
assert db.table_exists(["test_ns", "test_table"]) is True
|
||||
assert db.table_exists(["test_ns", "missing"]) is False
|
||||
assert "test_table" not in db
|
||||
assert "test_table" in db.table_names(namespace_path=["test_ns"])
|
||||
assert "test_table" in db.list_tables(namespace_path=["test_ns"]).tables
|
||||
|
||||
@@ -420,7 +449,10 @@ class TestNamespaceConnection:
|
||||
assert opened.namespace == ["test_ns"]
|
||||
|
||||
db.drop_table("test_table", namespace_path=["test_ns"])
|
||||
assert db.table_exists(["test_ns", "test_table"]) is False
|
||||
assert db.list_tables(namespace_path=["test_ns"]).tables == []
|
||||
db.drop_table("root_table")
|
||||
assert "root_table" not in db
|
||||
db.drop_namespace(["test_ns"])
|
||||
assert "test_ns" not in db.list_namespaces().namespaces
|
||||
|
||||
@@ -942,12 +974,18 @@ class TestAsyncNamespaceConnection:
|
||||
assert "test_ns" in (await db.list_namespaces()).namespaces
|
||||
|
||||
schema = pa.schema([pa.field("id", pa.int64())])
|
||||
await db.create_table("root_table", schema=schema)
|
||||
assert await db.table_exists(["root_table"]) is True
|
||||
assert await db.table_exists(["missing"]) is False
|
||||
table = await db.create_table(
|
||||
"test_table", schema=schema, namespace_path=["test_ns"]
|
||||
)
|
||||
assert table._namespace_path == ["test_ns"]
|
||||
assert table._namespace_client is None
|
||||
assert table._route_pushdown_to_rust is True
|
||||
assert await db.table_exists(["test_ns", "test_table"]) is True
|
||||
assert await db.table_exists(["test_ns", "missing"]) is False
|
||||
assert await db.table_exists(["test_table"]) is False
|
||||
assert "test_table" in await db.table_names(namespace_path=["test_ns"])
|
||||
assert "test_table" in (await db.list_tables(namespace_path=["test_ns"])).tables
|
||||
|
||||
@@ -955,7 +993,10 @@ class TestAsyncNamespaceConnection:
|
||||
assert opened._namespace_path == ["test_ns"]
|
||||
|
||||
await db.drop_table("test_table", namespace_path=["test_ns"])
|
||||
assert await db.table_exists(["test_ns", "test_table"]) is False
|
||||
assert (await db.list_tables(namespace_path=["test_ns"])).tables == []
|
||||
await db.drop_table("root_table")
|
||||
assert await db.table_exists(["root_table"]) is False
|
||||
await db.drop_namespace(["test_ns"])
|
||||
assert "test_ns" not in (await db.list_namespaces()).namespaces
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import time
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
from unittest.mock import MagicMock, patch
|
||||
import uuid
|
||||
import warnings
|
||||
from packaging.version import Version
|
||||
from lance_namespace.errors import TableNotFoundError
|
||||
|
||||
@@ -461,6 +462,31 @@ def test_remote_table_exists_rechecks_cached_table():
|
||||
assert requests == ["/v1/table/ns$table/describe/"] * 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("status", [200, 404, 403])
|
||||
def test_remote_membership_uses_direct_lookup(status):
|
||||
requests = []
|
||||
|
||||
def handler(request):
|
||||
requests.append(request.path)
|
||||
assert request.command == "POST"
|
||||
assert request.path == "/v1/table/t129/describe/"
|
||||
request.send_response(status)
|
||||
request.send_header("Content-Type", "application/json")
|
||||
request.end_headers()
|
||||
request.wfile.write(b"{}" if status == 200 else b"lookup failed")
|
||||
|
||||
with mock_lancedb_connection(handler) as db:
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("error", DeprecationWarning)
|
||||
if status in (200, 404):
|
||||
assert ("t129" in db) is (status == 200)
|
||||
else:
|
||||
with pytest.raises(HttpError) as exc_info:
|
||||
"t129" in db
|
||||
assert exc_info.value.status_code == status
|
||||
assert requests == ["/v1/table/t129/describe/"]
|
||||
|
||||
|
||||
def paginated_table_listing_handler(request):
|
||||
url = urlparse(request.path)
|
||||
assert url.path in {
|
||||
@@ -2531,6 +2557,144 @@ async def test_remote_job_wait_disconnection_timeout_can_be_resumed(sync):
|
||||
assert exc.value.__cause__.is_transport_error is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("sync", [False, True])
|
||||
@pytest.mark.parametrize(
|
||||
"job_type", ["function_refresh", "computed_refresh", "refresh_column"]
|
||||
)
|
||||
@pytest.mark.parametrize("running", [False, True])
|
||||
@pytest.mark.parametrize("rows_failed", [0, 8])
|
||||
async def test_reopened_refresh_job_wait_returns_typed_result(
|
||||
sync, job_type, running, rows_failed
|
||||
):
|
||||
terminal_result = {
|
||||
"rows_assigned": 400 - rows_failed,
|
||||
"rows_failed": rows_failed,
|
||||
"rows_remaining": 0,
|
||||
"source_version": 7,
|
||||
"published_version": 8,
|
||||
"summary": {"future_field": True},
|
||||
}
|
||||
polls = 0
|
||||
|
||||
def handler(request):
|
||||
nonlocal polls
|
||||
assert request.path == "/v1/jobs/describe"
|
||||
payload = json.loads(request.rfile.read(int(request.headers["Content-Length"])))
|
||||
assert payload == {"job_id": "refresh-1"}
|
||||
polls += 1
|
||||
in_progress = running and polls <= 2
|
||||
response = {
|
||||
"job_id": "refresh-1",
|
||||
"job_type": job_type,
|
||||
"job_state": "IN_PROGRESS" if in_progress else "DONE",
|
||||
"creation_ms": 1000,
|
||||
"spec": {"column": "derived"},
|
||||
}
|
||||
if not in_progress:
|
||||
response["result"] = terminal_result
|
||||
request.send_response(200)
|
||||
request.send_header("Content-Type", "application/json")
|
||||
request.end_headers()
|
||||
request.wfile.write(json.dumps(response).encode())
|
||||
|
||||
observed = []
|
||||
if sync:
|
||||
with mock_lancedb_connection(handler) as db:
|
||||
job = db.open_job("refresh-1")
|
||||
assert job.id == "refresh-1"
|
||||
assert job.spec == {"column": "derived"}
|
||||
result = job.wait(timeout=timedelta(seconds=5), progress=observed.append)
|
||||
assert job.wait() == result
|
||||
job.refresh()
|
||||
assert job.result == terminal_result
|
||||
else:
|
||||
async with mock_lancedb_connection_async(handler) as db:
|
||||
job = await db.open_job("refresh-1")
|
||||
assert job.id == "refresh-1"
|
||||
assert job.spec == {"column": "derived"}
|
||||
result = await job.wait(
|
||||
timeout=timedelta(seconds=5), progress=observed.append
|
||||
)
|
||||
assert await job.wait() == result
|
||||
await job.refresh()
|
||||
assert job.result == terminal_result
|
||||
|
||||
assert isinstance(result, lancedb.RefreshColumnResult)
|
||||
assert result == lancedb.RefreshColumnResult.model_validate(terminal_result)
|
||||
assert result.rows_failed == rows_failed
|
||||
assert observed[-1]["state"] == "finished"
|
||||
if running:
|
||||
assert observed[0]["state"] == "running"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("sync", [False, True])
|
||||
@pytest.mark.parametrize("terminal_result", [None, {}])
|
||||
async def test_reopened_refresh_job_rejects_missing_or_invalid_result(
|
||||
sync, terminal_result
|
||||
):
|
||||
def handler(request):
|
||||
assert request.path == "/v1/jobs/describe"
|
||||
request.rfile.read(int(request.headers["Content-Length"]))
|
||||
request.send_response(200)
|
||||
request.end_headers()
|
||||
request.wfile.write(
|
||||
json.dumps(
|
||||
{
|
||||
"job_id": "refresh-1",
|
||||
"job_type": "function_refresh",
|
||||
"job_state": "DONE",
|
||||
"result": terminal_result,
|
||||
}
|
||||
).encode()
|
||||
)
|
||||
|
||||
if sync:
|
||||
with mock_lancedb_connection(handler) as db:
|
||||
job = db.open_job("refresh-1")
|
||||
with pytest.raises(HttpError, match="typed job"):
|
||||
job.wait()
|
||||
else:
|
||||
async with mock_lancedb_connection_async(handler) as db:
|
||||
job = await db.open_job("refresh-1")
|
||||
with pytest.raises(HttpError, match="typed job"):
|
||||
await job.wait()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("sync", [False, True])
|
||||
async def test_reopened_unit_job_ignores_additive_result_payload(sync):
|
||||
terminal_result = {"future_field": True}
|
||||
|
||||
def handler(request):
|
||||
assert request.path == "/v1/jobs/describe"
|
||||
request.rfile.read(int(request.headers["Content-Length"]))
|
||||
request.send_response(200)
|
||||
request.end_headers()
|
||||
request.wfile.write(
|
||||
json.dumps(
|
||||
{
|
||||
"job_id": "index-1",
|
||||
"job_type": "create_index",
|
||||
"job_state": "DONE",
|
||||
"result": terminal_result,
|
||||
}
|
||||
).encode()
|
||||
)
|
||||
|
||||
if sync:
|
||||
with mock_lancedb_connection(handler) as db:
|
||||
job = db.open_job("index-1")
|
||||
assert job.wait() is None
|
||||
assert job.result == terminal_result
|
||||
else:
|
||||
async with mock_lancedb_connection_async(handler) as db:
|
||||
job = await db.open_job("index-1")
|
||||
assert await job.wait() is None
|
||||
assert job.result == terminal_result
|
||||
|
||||
|
||||
@pytest.mark.parametrize("payload", [b"{", b"{}"])
|
||||
def test_remote_job_wait_does_not_retry_malformed_description(payload):
|
||||
polls = 0
|
||||
@@ -6278,6 +6442,8 @@ def test_remote_function_registration_transports_max_concurrency():
|
||||
def registered(value: float) -> float:
|
||||
return value
|
||||
|
||||
definition["runtime_digest"] = registered.registration_request.runtime.digest
|
||||
|
||||
class RegistrationServer(flight.FlightServerBase):
|
||||
def __init__(self):
|
||||
super().__init__("grpc://127.0.0.1:0")
|
||||
@@ -6296,6 +6462,7 @@ def test_remote_function_registration_transports_max_concurrency():
|
||||
assert len(server.tickets) == 1
|
||||
assert b'"max_concurrency":4' in server.tickets[0]
|
||||
assert version.max_concurrency == 4
|
||||
assert version.runtime_digest == registered.registration_request.runtime.digest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -58,8 +58,8 @@ def test_legacy_table_replace_field_metadata(legacy_table):
|
||||
]
|
||||
|
||||
|
||||
def respond(request, body):
|
||||
request.send_response(200)
|
||||
def respond(request, body, status=200):
|
||||
request.send_response(status)
|
||||
request.send_header("Content-Type", "application/json")
|
||||
request.end_headers()
|
||||
request.wfile.write(json.dumps(body).encode())
|
||||
@@ -78,12 +78,20 @@ def test_remote_unsupported_properties(attribute):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tables", [[], ["first", "last"]])
|
||||
def test_remote_len_and_contains_follow_pages(tables):
|
||||
def test_remote_len_paginates_and_contains_looks_up_table(tables):
|
||||
requests = []
|
||||
|
||||
def handler(request):
|
||||
requests.append(request.path)
|
||||
query = parse_qs(urlparse(request.path).query)
|
||||
url = urlparse(request.path)
|
||||
if request.command == "POST":
|
||||
name = url.path.split("/")[3]
|
||||
assert url.path == f"/v1/table/{name}/describe/"
|
||||
respond(request, {}, status=200 if name in tables else 404)
|
||||
return
|
||||
assert request.command == "GET"
|
||||
assert url.path == "/v1/namespace/$/table/list"
|
||||
query = parse_qs(url.query)
|
||||
if tables and "page_token" not in query:
|
||||
respond(request, {"tables": [tables[0]], "page_token": "opaque-next"})
|
||||
else:
|
||||
@@ -93,11 +101,12 @@ def test_remote_len_and_contains_follow_pages(tables):
|
||||
|
||||
with mock_lancedb_connection(handler) as db:
|
||||
assert len(db) == len(tables)
|
||||
assert ("last" in db) == bool(tables)
|
||||
assert "missing" not in db
|
||||
assert len(requests) == (2 if tables else 1)
|
||||
requests.clear()
|
||||
assert ("first" in db) == bool(tables)
|
||||
assert len(requests) == 1
|
||||
for name in ("last", "missing", "first"):
|
||||
assert (name in db) is (name in tables)
|
||||
assert requests == [f"/v1/table/{name}/describe/"]
|
||||
requests.clear()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("namespace", [[], ["parent", "child"]])
|
||||
|
||||
@@ -4,12 +4,30 @@
|
||||
from typing import assert_type
|
||||
|
||||
import lancedb
|
||||
from lancedb import AsyncConnection, DBConnection
|
||||
from lancedb import AsyncCatalog, AsyncConnection, Catalog, DBConnection
|
||||
|
||||
|
||||
def check_connect_type() -> None:
|
||||
assert_type(lancedb.connect("memory://"), DBConnection)
|
||||
assert_type(
|
||||
lancedb.connect_catalog(
|
||||
uri="db://analytics",
|
||||
api_key="secret",
|
||||
region="us-west-2",
|
||||
host_override="https://my-server.example",
|
||||
),
|
||||
Catalog,
|
||||
)
|
||||
|
||||
|
||||
async def check_connect_async_type() -> None:
|
||||
assert_type(await lancedb.connect_async("memory://"), AsyncConnection)
|
||||
assert_type(
|
||||
await lancedb.connect_catalog_async(
|
||||
uri="db://analytics",
|
||||
api_key="secret",
|
||||
region="us-west-2",
|
||||
host_override="https://my-server.example",
|
||||
),
|
||||
AsyncCatalog,
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -127,7 +128,8 @@ impl DatabaseNames {
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
#[pyo3(signature = (endpoint, *, api_key=None, client_config=None, sql_host_override=None, read_consistency_interval=None, oauth_config=None))]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[pyo3(signature = (endpoint, *, api_key=None, client_config=None, sql_host_override=None, read_consistency_interval=None, oauth_config=None, storage_options=None))]
|
||||
pub fn connect_catalog(
|
||||
py: Python<'_>,
|
||||
endpoint: String,
|
||||
@@ -136,6 +138,7 @@ pub fn connect_catalog(
|
||||
sql_host_override: Option<String>,
|
||||
read_consistency_interval: Option<f64>,
|
||||
oauth_config: Option<crate::oauth::PyOAuthConfig>,
|
||||
storage_options: Option<HashMap<String, String>>,
|
||||
) -> PyResult<Bound<'_, PyAny>> {
|
||||
let interval = read_consistency_interval
|
||||
.map(Duration::try_from_secs_f64)
|
||||
@@ -151,6 +154,9 @@ pub fn connect_catalog(
|
||||
if let Some(config) = client_config {
|
||||
builder = builder.client_config(config.into());
|
||||
}
|
||||
if let Some(options) = storage_options {
|
||||
builder = builder.storage_options(options);
|
||||
}
|
||||
if let Some(endpoint) = sql_host_override {
|
||||
builder = builder.sql_host_override(endpoint);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ use lancedb::{
|
||||
connection::NamespaceClientPushdownOperation,
|
||||
database::namespace::LanceNamespaceDatabase,
|
||||
database::{CreateTableMode, Database, ReadConsistency},
|
||||
function::GpuClass as LanceGpuClass,
|
||||
function::{GpuClass as LanceGpuClass, RefreshColumnResult},
|
||||
graph::PropertyGraphDefinition,
|
||||
};
|
||||
use pyo3::{
|
||||
@@ -854,7 +854,14 @@ impl Connection {
|
||||
let inner = self_.get_inner()?.clone();
|
||||
future_into_py(self_.py(), async move {
|
||||
let job = inner.open_job(&job_id).await.infer_error()?;
|
||||
Ok(crate::job::Job::new(job))
|
||||
match job.job_type().as_deref() {
|
||||
Some("function_refresh" | "computed_refresh" | "refresh_column") => {
|
||||
Ok(crate::job::Job::new_typed(
|
||||
job.into_typed::<RefreshColumnResult>().infer_error()?,
|
||||
))
|
||||
}
|
||||
_ => Ok(crate::job::Job::new(job)),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ pub fn _lancedb(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(table::tokenize, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(permutation::async_permutation_builder, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(util::validate_table_name, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(util::validate_conda_requirement, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(util::validate_function_retry_policy, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(util::parse_field_path, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(query::fts_query_to_json, m)?)?;
|
||||
|
||||
@@ -9,6 +9,7 @@ use pyo3::{
|
||||
exceptions::{PyRuntimeError, PyValueError},
|
||||
pyfunction,
|
||||
};
|
||||
use rattler_conda_types::{MatchSpec, ParseStrictness};
|
||||
|
||||
/// A wrapper around a rust builder
|
||||
///
|
||||
@@ -61,6 +62,13 @@ pub fn validate_table_name(table_name: &str) -> PyResult<()> {
|
||||
.map_err(|e| PyValueError::new_err(e.to_string()))
|
||||
}
|
||||
|
||||
#[pyfunction(name = "_validate_conda_requirement")]
|
||||
pub fn validate_conda_requirement(requirement: &str) -> PyResult<()> {
|
||||
MatchSpec::from_str(requirement, ParseStrictness::Lenient)
|
||||
.map(|_| ())
|
||||
.map_err(|error| PyValueError::new_err(error.to_string()))
|
||||
}
|
||||
|
||||
/// Parse field references with the same identifier syntax as Lance writes.
|
||||
#[pyfunction(name = "_parse_field_path")]
|
||||
pub fn parse_field_path(path: &str) -> PyResult<Vec<String>> {
|
||||
|
||||
Generated
+90
-88
@@ -1,5 +1,5 @@
|
||||
version = 1
|
||||
revision = 5
|
||||
revision = 3
|
||||
requires-python = ">=3.10"
|
||||
resolution-markers = [
|
||||
"python_full_version >= '3.14' and sys_platform == 'win32'",
|
||||
@@ -915,7 +915,7 @@ name = "cuda-bindings"
|
||||
version = "13.3.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "cuda-pathfinder" },
|
||||
{ name = "cuda-pathfinder", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a9/21/8464d133752951c154feafb3b65c297e7d80f301183d220bec4c830f1441/cuda_bindings-13.3.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:120fcc53d57903df529c3486962c56528cba5b7d6c57c99537320ed9922c8b86", size = 6073403, upload-time = "2026-05-29T23:11:36.22Z" },
|
||||
@@ -950,37 +950,37 @@ wheels = [
|
||||
|
||||
[package.optional-dependencies]
|
||||
cublas = [
|
||||
{ name = "nvidia-cublas" },
|
||||
{ name = "nvidia-cublas", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
cudart = [
|
||||
{ name = "nvidia-cuda-runtime" },
|
||||
{ name = "nvidia-cuda-runtime", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
cufft = [
|
||||
{ name = "nvidia-cufft" },
|
||||
{ name = "nvidia-cufft", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
cufile = [
|
||||
{ name = "nvidia-cufile" },
|
||||
{ name = "nvidia-cufile", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
cupti = [
|
||||
{ name = "nvidia-cuda-cupti" },
|
||||
{ name = "nvidia-cuda-cupti", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
curand = [
|
||||
{ name = "nvidia-curand" },
|
||||
{ name = "nvidia-curand", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
cusolver = [
|
||||
{ name = "nvidia-cusolver" },
|
||||
{ name = "nvidia-cusolver", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
cusparse = [
|
||||
{ name = "nvidia-cusparse" },
|
||||
{ name = "nvidia-cusparse", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
nvjitlink = [
|
||||
{ name = "nvidia-nvjitlink" },
|
||||
{ name = "nvidia-nvjitlink", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
nvrtc = [
|
||||
{ name = "nvidia-cuda-nvrtc" },
|
||||
{ name = "nvidia-cuda-nvrtc", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
nvtx = [
|
||||
{ name = "nvidia-nvtx" },
|
||||
{ name = "nvidia-nvtx", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1140,7 +1140,7 @@ name = "exceptiongroup"
|
||||
version = "1.3.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "typing-extensions" },
|
||||
{ name = "typing-extensions", marker = "python_full_version < '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" }
|
||||
wheels = [
|
||||
@@ -1559,16 +1559,16 @@ resolution-markers = [
|
||||
"python_full_version < '3.11' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "cachetools" },
|
||||
{ name = "certifi" },
|
||||
{ name = "httpx" },
|
||||
{ name = "ibm-cos-sdk" },
|
||||
{ name = "lomond" },
|
||||
{ name = "packaging" },
|
||||
{ name = "pandas", version = "2.2.3", source = { registry = "https://pypi.org/simple" } },
|
||||
{ name = "requests" },
|
||||
{ name = "tabulate" },
|
||||
{ name = "urllib3" },
|
||||
{ name = "cachetools", marker = "python_full_version < '3.11'" },
|
||||
{ name = "certifi", marker = "python_full_version < '3.11'" },
|
||||
{ name = "httpx", marker = "python_full_version < '3.11'" },
|
||||
{ name = "ibm-cos-sdk", marker = "python_full_version < '3.11'" },
|
||||
{ name = "lomond", marker = "python_full_version < '3.11'" },
|
||||
{ name = "packaging", marker = "python_full_version < '3.11'" },
|
||||
{ name = "pandas", version = "2.2.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
||||
{ name = "requests", marker = "python_full_version < '3.11'" },
|
||||
{ name = "tabulate", marker = "python_full_version < '3.11'" },
|
||||
{ name = "urllib3", marker = "python_full_version < '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/c7/56/2e3df38a1f13062095d7bde23c87a92f3898982993a15186b1bfecbd206f/ibm_watsonx_ai-1.3.42.tar.gz", hash = "sha256:ee5be59009004245d957ce97d1227355516df95a2640189749487614fef674ff", size = 688651, upload-time = "2025-10-01T13:35:41.527Z" }
|
||||
wheels = [
|
||||
@@ -1593,17 +1593,17 @@ resolution-markers = [
|
||||
"python_full_version == '3.11.*' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "cachetools" },
|
||||
{ name = "certifi" },
|
||||
{ name = "httpx" },
|
||||
{ name = "ibm-cos-sdk" },
|
||||
{ name = "lomond" },
|
||||
{ name = "packaging" },
|
||||
{ name = "pandas", version = "2.3.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.14'" },
|
||||
{ name = "cachetools", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "certifi", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "httpx", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "ibm-cos-sdk", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "lomond", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "packaging", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "pandas", version = "2.3.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.14'" },
|
||||
{ name = "pandas", version = "3.0.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.14'" },
|
||||
{ name = "requests" },
|
||||
{ name = "tabulate" },
|
||||
{ name = "urllib3" },
|
||||
{ name = "requests", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "tabulate", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "urllib3", marker = "python_full_version >= '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/29/a3/c756b534696ab2f3f29882fdb7ca7198b7a5c94e10c0a3a327853d6d6b79/ibm_watsonx_ai-1.5.14.tar.gz", hash = "sha256:a756488bd57e87c0fc51be42dcba871143cfe0ac1e805c497c5047e1e4f13e9d", size = 735804, upload-time = "2026-06-22T12:32:43.85Z" }
|
||||
wheels = [
|
||||
@@ -1681,17 +1681,17 @@ resolution-markers = [
|
||||
"python_full_version < '3.11' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||
{ name = "decorator" },
|
||||
{ name = "exceptiongroup" },
|
||||
{ name = "jedi" },
|
||||
{ name = "matplotlib-inline" },
|
||||
{ name = "pexpect", marker = "sys_platform != 'emscripten' and sys_platform != 'win32'" },
|
||||
{ name = "prompt-toolkit" },
|
||||
{ name = "pygments" },
|
||||
{ name = "stack-data" },
|
||||
{ name = "traitlets" },
|
||||
{ name = "typing-extensions" },
|
||||
{ name = "colorama", marker = "python_full_version < '3.11' and sys_platform == 'win32'" },
|
||||
{ name = "decorator", marker = "python_full_version < '3.11'" },
|
||||
{ name = "exceptiongroup", marker = "python_full_version < '3.11'" },
|
||||
{ name = "jedi", marker = "python_full_version < '3.11'" },
|
||||
{ name = "matplotlib-inline", marker = "python_full_version < '3.11'" },
|
||||
{ name = "pexpect", marker = "python_full_version < '3.11' and sys_platform != 'emscripten' and sys_platform != 'win32'" },
|
||||
{ name = "prompt-toolkit", marker = "python_full_version < '3.11'" },
|
||||
{ name = "pygments", marker = "python_full_version < '3.11'" },
|
||||
{ name = "stack-data", marker = "python_full_version < '3.11'" },
|
||||
{ name = "traitlets", marker = "python_full_version < '3.11'" },
|
||||
{ name = "typing-extensions", marker = "python_full_version < '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/40/18/f8598d287006885e7136451fdea0755af4ebcbfe342836f24deefaed1164/ipython-8.39.0.tar.gz", hash = "sha256:4110ae96012c379b8b6db898a07e186c40a2a1ef5d57a7fa83166047d9da7624", size = 5513971, upload-time = "2026-03-27T10:02:13.94Z" }
|
||||
wheels = [
|
||||
@@ -1716,18 +1716,18 @@ resolution-markers = [
|
||||
"python_full_version == '3.11.*' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||
{ name = "decorator" },
|
||||
{ name = "ipython-pygments-lexers" },
|
||||
{ name = "jedi" },
|
||||
{ name = "matplotlib-inline" },
|
||||
{ name = "pexpect", marker = "sys_platform != 'emscripten' and sys_platform != 'win32'" },
|
||||
{ name = "prompt-toolkit" },
|
||||
{ name = "psutil", marker = "sys_platform != 'cygwin' and sys_platform != 'emscripten'" },
|
||||
{ name = "pygments" },
|
||||
{ name = "stack-data" },
|
||||
{ name = "traitlets" },
|
||||
{ name = "typing-extensions", marker = "python_full_version < '3.12'" },
|
||||
{ name = "colorama", marker = "python_full_version >= '3.11' and sys_platform == 'win32'" },
|
||||
{ name = "decorator", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "ipython-pygments-lexers", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "jedi", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "matplotlib-inline", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "pexpect", marker = "python_full_version >= '3.11' and sys_platform != 'emscripten' and sys_platform != 'win32'" },
|
||||
{ name = "prompt-toolkit", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "psutil", marker = "python_full_version >= '3.11' and sys_platform != 'cygwin' and sys_platform != 'emscripten'" },
|
||||
{ name = "pygments", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "stack-data", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "traitlets", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "typing-extensions", marker = "python_full_version == '3.11.*'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/53/59/165d3b4d75cc34add3122c4417ecb229085140ac573103c223cd01dde96f/ipython-9.15.0.tar.gz", hash = "sha256:da2819ce2aa83135257df830660b1176d986c3d2876db24df01974fa955b2756", size = 4442580, upload-time = "2026-06-26T11:03:35.913Z" }
|
||||
wheels = [
|
||||
@@ -1739,7 +1739,7 @@ name = "ipython-pygments-lexers"
|
||||
version = "1.1.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pygments" },
|
||||
{ name = "pygments", marker = "python_full_version >= '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/ef/4c/5dd1d8af08107f88c7f741ead7a40854b8ac24ddf9ae850afbcf698aa552/ipython_pygments_lexers-1.1.1.tar.gz", hash = "sha256:09c0138009e56b6854f9535736f4171d855c8c08a563a0dcd8022f78355c7e81", size = 8393, upload-time = "2025-01-17T11:24:34.505Z" }
|
||||
wheels = [
|
||||
@@ -3040,7 +3040,7 @@ name = "nvidia-cudnn-cu13"
|
||||
version = "9.19.0.56"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "nvidia-cublas" },
|
||||
{ name = "nvidia-cublas", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f1/84/26025437c1e6b61a707442184fa0c03d083b661adf3a3eecfd6d21677740/nvidia_cudnn_cu13-9.19.0.56-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:6ed29ffaee1176c612daf442e4dd6cfeb6a0caa43ddcbeb59da94953030b1be4", size = 433781201, upload-time = "2026-02-03T20:40:53.805Z" },
|
||||
@@ -3052,7 +3052,7 @@ name = "nvidia-cufft"
|
||||
version = "12.0.0.61"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "nvidia-nvjitlink" },
|
||||
{ name = "nvidia-nvjitlink", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/8b/ae/f417a75c0259e85c1d2f83ca4e960289a5f814ed0cea74d18c353d3e989d/nvidia_cufft-12.0.0.61-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:2708c852ef8cd89d1d2068bdbece0aa188813a0c934db3779b9b1faa8442e5f5", size = 214053554, upload-time = "2025-09-04T08:31:38.196Z" },
|
||||
@@ -3082,9 +3082,9 @@ name = "nvidia-cusolver"
|
||||
version = "12.0.4.66"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "nvidia-cublas" },
|
||||
{ name = "nvidia-cusparse" },
|
||||
{ name = "nvidia-nvjitlink" },
|
||||
{ name = "nvidia-cublas", marker = "sys_platform == 'linux'" },
|
||||
{ name = "nvidia-cusparse", marker = "sys_platform == 'linux'" },
|
||||
{ name = "nvidia-nvjitlink", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c8/c3/b30c9e935fc01e3da443ec0116ed1b2a009bb867f5324d3f2d7e533e776b/nvidia_cusolver-12.0.4.66-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:02c2457eaa9e39de20f880f4bd8820e6a1cfb9f9a34f820eb12a155aa5bc92d2", size = 223467760, upload-time = "2025-09-04T08:33:04.222Z" },
|
||||
@@ -3096,7 +3096,7 @@ name = "nvidia-cusparse"
|
||||
version = "12.6.3.3"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "nvidia-nvjitlink" },
|
||||
{ name = "nvidia-nvjitlink", marker = "sys_platform == 'linux'" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f8/94/5c26f33738ae35276672f12615a64bd008ed5be6d1ebcb23579285d960a9/nvidia_cusparse-12.6.3.3-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:80bcc4662f23f1054ee334a15c72b8940402975e0eab63178fc7e670aa59472c", size = 162155568, upload-time = "2025-09-04T08:33:42.864Z" },
|
||||
@@ -3297,10 +3297,10 @@ resolution-markers = [
|
||||
"python_full_version < '3.11' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" } },
|
||||
{ name = "python-dateutil" },
|
||||
{ name = "pytz" },
|
||||
{ name = "tzdata" },
|
||||
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
||||
{ name = "python-dateutil", marker = "python_full_version < '3.11'" },
|
||||
{ name = "pytz", marker = "python_full_version < '3.11'" },
|
||||
{ name = "tzdata", marker = "python_full_version < '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/9c/d6/9f8431bacc2e19dca897724cd097b1bb224a6ad5433784a44b587c7c13af/pandas-2.2.3.tar.gz", hash = "sha256:4f18ba62b61d7e192368b84517265a99b4d7ee8912f8708660fb4a366cc82667", size = 4399213, upload-time = "2024-09-20T13:10:04.827Z" }
|
||||
wheels = [
|
||||
@@ -3353,11 +3353,11 @@ resolution-markers = [
|
||||
"python_full_version == '3.11.*' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12' or python_full_version >= '3.14'" },
|
||||
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" },
|
||||
{ name = "numpy", version = "2.5.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12' and python_full_version < '3.14'" },
|
||||
{ name = "python-dateutil" },
|
||||
{ name = "pytz" },
|
||||
{ name = "tzdata" },
|
||||
{ name = "python-dateutil", marker = "python_full_version >= '3.11' and python_full_version < '3.14'" },
|
||||
{ name = "pytz", marker = "python_full_version >= '3.11' and python_full_version < '3.14'" },
|
||||
{ name = "tzdata", marker = "python_full_version >= '3.11' and python_full_version < '3.14'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/33/01/d40b85317f86cf08d853a4f495195c73815fdf205eef3993821720274518/pandas-2.3.3.tar.gz", hash = "sha256:e05e1af93b977f7eafa636d043f9f94c7ee3ac81af99c13508215942e64c993b", size = 4495223, upload-time = "2025-09-29T23:34:51.853Z" }
|
||||
wheels = [
|
||||
@@ -3422,9 +3422,9 @@ resolution-markers = [
|
||||
"python_full_version >= '3.14' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "numpy", version = "2.5.1", source = { registry = "https://pypi.org/simple" } },
|
||||
{ name = "python-dateutil" },
|
||||
{ name = "tzdata", marker = "sys_platform == 'emscripten' or sys_platform == 'win32'" },
|
||||
{ name = "numpy", version = "2.5.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.14'" },
|
||||
{ name = "python-dateutil", marker = "python_full_version >= '3.14'" },
|
||||
{ name = "tzdata", marker = "(python_full_version >= '3.14' and sys_platform == 'emscripten') or (python_full_version >= '3.14' and sys_platform == 'win32')" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f8/87/4341c6252d1c47b08768c3d25ac487362bf403f0313ddae4a2a26c9b1b4c/pandas-3.0.3.tar.gz", hash = "sha256:696a4a00a2a2a35d4e5deb3fc946641b96c944f02230e4f76137fe35d806c4fc", size = 4651414, upload-time = "2026-05-11T18:54:29.21Z" }
|
||||
wheels = [
|
||||
@@ -3532,7 +3532,7 @@ name = "pexpect"
|
||||
version = "4.9.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "ptyprocess" },
|
||||
{ name = "ptyprocess", marker = "(python_full_version < '3.14' and sys_platform == 'emscripten') or (python_full_version < '3.14' and sys_platform == 'win32') or (sys_platform != 'emscripten' and sys_platform != 'win32')" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450, upload-time = "2023-11-25T09:07:26.339Z" }
|
||||
wheels = [
|
||||
@@ -4314,7 +4314,9 @@ dependencies = [
|
||||
wheels = [
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1aPvIp/pylance-15.0.0b19-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:0a672e7e925f8913a3d748686dae7e45bf115e896271e7c44f2301ec1113696e" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_2kSEvu/pylance-15.0.0b19-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:475a5b7e0e654267276051edd2fad249971c0a9f697556ac3865fd24bc6b25e7" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1bNmUH/pylance-15.0.0b19-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:094c2b766ca0abb056eed72e970aa96a1ff7e2821120a880ac1376a70c71af3b" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1aX2uo/pylance-15.0.0b19-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:8a5aff3f5c0c2a6221cbed0fd1a2f2fc22bbc21842bdbfb70995ced4da85a64e" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_G3hVe/pylance-15.0.0b19-cp310-abi3-win_amd64.whl", hash = "sha256:0a125f108c7e551286a1ae105caebd8cc9af47761907caf95cc4da7a886c6b04" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5134,10 +5136,10 @@ resolution-markers = [
|
||||
"python_full_version < '3.11' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "joblib" },
|
||||
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" } },
|
||||
{ name = "scipy", version = "1.15.3", source = { registry = "https://pypi.org/simple" } },
|
||||
{ name = "threadpoolctl" },
|
||||
{ name = "joblib", marker = "python_full_version < '3.11'" },
|
||||
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
||||
{ name = "scipy", version = "1.15.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
||||
{ name = "threadpoolctl", marker = "python_full_version < '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/98/c2/a7855e41c9d285dfe86dc50b250978105dce513d6e459ea66a6aeb0e1e0c/scikit_learn-1.7.2.tar.gz", hash = "sha256:20e9e49ecd130598f1ca38a1d85090e1a600147b9c02fa6f15d69cb53d968fda", size = 7193136, upload-time = "2025-09-09T08:21:29.075Z" }
|
||||
wheels = [
|
||||
@@ -5191,13 +5193,13 @@ resolution-markers = [
|
||||
"python_full_version == '3.11.*' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "joblib" },
|
||||
{ name = "narwhals" },
|
||||
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
|
||||
{ name = "joblib", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "narwhals", marker = "python_full_version >= '3.11'" },
|
||||
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" },
|
||||
{ name = "numpy", version = "2.5.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
|
||||
{ name = "scipy", version = "1.17.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
|
||||
{ name = "scipy", version = "1.17.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" },
|
||||
{ name = "scipy", version = "1.18.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
|
||||
{ name = "threadpoolctl" },
|
||||
{ name = "threadpoolctl", marker = "python_full_version >= '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/fa/6f/37092bdb25f712817231799fc5674d8e704066a8a70c1d2d40517e18b4ab/scikit_learn-1.9.0.tar.gz", hash = "sha256:8833266989d3a5110178a9fae30783675460724d0e1efb13b14901d2c660c557", size = 7750767, upload-time = "2026-06-02T11:54:32.706Z" }
|
||||
wheels = [
|
||||
@@ -5243,7 +5245,7 @@ resolution-markers = [
|
||||
"python_full_version < '3.11' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" } },
|
||||
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/0f/37/6964b830433e654ec7485e45a00fc9a27cf868d622838f6b6d9c5ec0d532/scipy-1.15.3.tar.gz", hash = "sha256:eae3cf522bc7df64b42cad3925c876e1b0b6c35c1337c93e12c0f366f55b0eaf", size = 59419214, upload-time = "2025-05-08T16:13:05.955Z" }
|
||||
wheels = [
|
||||
@@ -5304,7 +5306,7 @@ resolution-markers = [
|
||||
"python_full_version == '3.11.*' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" } },
|
||||
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/7a/97/5a3609c4f8d58b039179648e62dd220f89864f56f7357f5d4f45c29eb2cc/scipy-1.17.1.tar.gz", hash = "sha256:95d8e012d8cb8816c226aef832200b1d45109ed4464303e997c5b13122b297c0", size = 30573822, upload-time = "2026-02-23T00:26:24.851Z" }
|
||||
wheels = [
|
||||
@@ -5385,7 +5387,7 @@ resolution-markers = [
|
||||
"python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'darwin'",
|
||||
]
|
||||
dependencies = [
|
||||
{ name = "numpy", version = "2.5.1", source = { registry = "https://pypi.org/simple" } },
|
||||
{ name = "numpy", version = "2.5.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a7/25/c2700dfaf6442b4effaa91af24ebce5dc9d31bb4a69706313aae70d72cd0/scipy-1.18.0.tar.gz", hash = "sha256:67b2ad2ad54c72ca6d04975a9b2df8c3638c34ddd5b28738e94fc2b57929d378", size = 30774447, upload-time = "2026-06-19T15:01:43.456Z" }
|
||||
wheels = [
|
||||
|
||||
Reference in New Issue
Block a user