mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-16 16:52:34 +00:00
This PR is part of the documentation revamp. Once the full set of PRs is merged, we’ll publish the combined site to staging for review before updating docs.lancedb.com. The curation, SQL and operations pages contain outdated claims and examples that do not reliably work as written. This corrects those pages against the reviewed SDK and local server evidence, including prepared statements, background jobs, cleanup and monitoring. Integration guides are grouped with their examples in #4533. Function and Secret-object documentation stays unpublished until its release. The two Function pages are listed in `.mintignore` and left out of the navigation, and the sections about them on other pages are MDX comments. Stacked on #4533. Each MDX file has one PR owner. Rebase onto main after #4533 is squash-merged. Local assembly, Mint validation and link checks pass, and the assembled site shows no Function or Secret-object content. A local release rehearsal that uncomments the drafts and restores the navigation also passes. Hold publication until this PR and lancedb/sophon#8688 are on `main`.
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
|
|
def test_sample_dataset():
|
|
# --8<-- [start:sample_dataset]
|
|
from tempfile import TemporaryDirectory
|
|
|
|
import lancedb
|
|
from lancedb.permutation import Permutation, permutation_builder
|
|
|
|
with TemporaryDirectory(prefix="lancedb-sampling-") as uri:
|
|
db = lancedb.connect(uri)
|
|
table = db.create_table("records", [{"id": i} for i in range(10)])
|
|
splits = (
|
|
permutation_builder(table).split_random(counts=[3, 7], seed=42).execute()
|
|
)
|
|
sample = Permutation.from_tables(table, splits, split=0).with_format("arrow")
|
|
selected_ids = []
|
|
for batch in sample.iter(batch_size=3):
|
|
selected_ids.extend(batch.column("id").to_pylist())
|
|
print(f"Selected {len(selected_ids)} rows: {selected_ids}")
|
|
# --8<-- [end:sample_dataset]
|
|
|
|
assert len(selected_ids) == 3
|
|
assert len(set(selected_ids)) == 3
|
|
assert all(0 <= value < 10 for value in selected_ids)
|