mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
Expand the Linux Python test run without pandas and pylance from two files to the suite while retaining the regular dependency run for optional-package modules. Move optional imports into tests that need them and use Arrow assertions where pandas is not required, preserving the existing behavioral assertions. Validation: - Physical no-pandas/no-pylance broad run: 2884 passed, 316 skipped, 8 existing marker cases deselected. - Regular affected suite: 1687 passed, 39 skipped. - Current-head hosted integration: all 15 checks and 4 workflows passed. Co-authored-by: importcpp <57519936+importcpp@users.noreply.github.com>
99 lines
3.8 KiB
Python
99 lines
3.8 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
from datetime import timedelta
|
|
|
|
import lancedb
|
|
import pytest
|
|
from lance_namespace import connect as connect_namespace_client
|
|
from lancedb import _lancedb
|
|
from lancedb.namespace import LanceNamespaceDBConnection
|
|
|
|
|
|
@pytest.mark.parametrize("seconds", [-1.0, -0.000001])
|
|
@pytest.mark.parametrize("kind", ["sync", "namespace", "namespace_async", "client"])
|
|
def test_negative_read_consistency_interval(tmp_path, seconds, kind):
|
|
if kind == "client":
|
|
pytest.importorskip("lance")
|
|
interval = timedelta(seconds=seconds)
|
|
with pytest.raises(ValueError, match="read_consistency_interval"):
|
|
if kind == "sync":
|
|
lancedb.connect(tmp_path, read_consistency_interval=interval)
|
|
elif kind == "client":
|
|
client = connect_namespace_client("dir", {"root": str(tmp_path)})
|
|
LanceNamespaceDBConnection(client, read_consistency_interval=interval)
|
|
else:
|
|
connect = (
|
|
lancedb.connect_namespace
|
|
if kind == "namespace"
|
|
else lancedb.connect_namespace_async
|
|
)
|
|
connect("dir", {"root": str(tmp_path)}, read_consistency_interval=interval)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize("seconds", [-1.0, -0.000001])
|
|
async def test_negative_async_read_consistency_interval(tmp_path, seconds):
|
|
with pytest.raises(ValueError, match="read_consistency_interval"):
|
|
await lancedb.connect_async(
|
|
tmp_path, read_consistency_interval=timedelta(seconds=seconds)
|
|
)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize("seconds", [float("nan"), float("inf"), -float("inf"), 1e30])
|
|
@pytest.mark.parametrize("kind", ["connect", "namespace", "client"])
|
|
async def test_binding_rejects_invalid_read_consistency_interval(
|
|
tmp_path, seconds, kind
|
|
):
|
|
if kind == "client":
|
|
pytest.importorskip("lance")
|
|
with pytest.raises(ValueError, match="read_consistency_interval"):
|
|
if kind == "connect":
|
|
await _lancedb.connect(str(tmp_path), read_consistency_interval=seconds)
|
|
elif kind == "namespace":
|
|
_lancedb.connect_namespace(
|
|
"dir", {"root": str(tmp_path)}, read_consistency_interval=seconds
|
|
)
|
|
else:
|
|
client = connect_namespace_client("dir", {"root": str(tmp_path)})
|
|
_lancedb.connect_namespace_client(client, read_consistency_interval=seconds)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize(
|
|
"interval", [None, timedelta(0), timedelta(microseconds=1), timedelta(seconds=5)]
|
|
)
|
|
async def test_valid_read_consistency_intervals(tmp_path, interval):
|
|
db = lancedb.connect(tmp_path / "sync", read_consistency_interval=interval)
|
|
assert db.read_consistency_interval == interval
|
|
db.close()
|
|
|
|
db = await lancedb.connect_async(
|
|
tmp_path / "async", read_consistency_interval=interval
|
|
)
|
|
assert await db.get_read_consistency_interval() == interval
|
|
db.close()
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"interval", [None, timedelta(0), timedelta(microseconds=1), timedelta(seconds=5)]
|
|
)
|
|
def test_valid_namespace_read_consistency_intervals(tmp_path, interval):
|
|
db = lancedb.connect_namespace(
|
|
"dir", {"root": str(tmp_path / "namespace")}, read_consistency_interval=interval
|
|
)
|
|
assert db.read_consistency_interval == interval
|
|
db.close()
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"interval", [None, timedelta(0), timedelta(microseconds=1), timedelta(seconds=5)]
|
|
)
|
|
def test_valid_namespace_client_read_consistency_intervals(tmp_path, interval):
|
|
pytest.importorskip("lance")
|
|
client = connect_namespace_client("dir", {"root": str(tmp_path / "client")})
|
|
db = LanceNamespaceDBConnection(client, read_consistency_interval=interval)
|
|
assert db.read_consistency_interval == interval
|
|
db.close()
|