mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-07 12:22:59 +00:00
Compare commits
5 Commits
remote-tab
...
add-data-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a72d8194f | ||
|
|
56ef4066c0 | ||
|
|
79693ef1d2 | ||
|
|
431f94e564 | ||
|
|
c1a7d65473 |
@@ -159,7 +159,7 @@ Allows you to set parameters when registering a `sentence-transformers` object.
|
|||||||
from lancedb.embeddings import get_registry
|
from lancedb.embeddings import get_registry
|
||||||
|
|
||||||
db = lancedb.connect("/tmp/db")
|
db = lancedb.connect("/tmp/db")
|
||||||
model = get_registry.get("sentence-transformers").create(name="BAAI/bge-small-en-v1.5", device="cpu")
|
model = get_registry().get("sentence-transformers").create(name="BAAI/bge-small-en-v1.5", device="cpu")
|
||||||
|
|
||||||
class Words(LanceModel):
|
class Words(LanceModel):
|
||||||
text: str = model.SourceField()
|
text: str = model.SourceField()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.6.9
|
current_version = 0.6.10
|
||||||
commit = True
|
commit = True
|
||||||
message = [python] Bump version: {current_version} → {new_version}
|
message = [python] Bump version: {current_version} → {new_version}
|
||||||
tag = True
|
tag = True
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "lancedb"
|
name = "lancedb"
|
||||||
version = "0.6.9"
|
version = "0.6.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deprecation",
|
"deprecation",
|
||||||
"pylance==0.10.12",
|
"pylance==0.10.12",
|
||||||
|
|||||||
@@ -281,6 +281,24 @@ class RemoteDBConnection(DBConnection):
|
|||||||
)
|
)
|
||||||
self._table_cache.pop(name)
|
self._table_cache.pop(name)
|
||||||
|
|
||||||
|
@override
|
||||||
|
def rename_table(self, cur_name: str, new_name: str):
|
||||||
|
"""Rename a table in the database.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
cur_name: str
|
||||||
|
The current name of the table.
|
||||||
|
new_name: str
|
||||||
|
The new name of the table.
|
||||||
|
"""
|
||||||
|
self._client.post(
|
||||||
|
f"/v1/table/{cur_name}/rename/",
|
||||||
|
json={"new_table_name": new_name},
|
||||||
|
)
|
||||||
|
self._table_cache.pop(cur_name)
|
||||||
|
self._table_cache[new_name] = True
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
"""Close the connection to the database."""
|
"""Close the connection to the database."""
|
||||||
self._client.close()
|
self._client.close()
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class RemoteTable(Table):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
def index_stats(self, index_uuid: str):
|
def index_stats(self, index_uuid: str):
|
||||||
"""List all the indices on the table"""
|
"""List all the stats of a specified index"""
|
||||||
resp = self._conn._client.post(
|
resp = self._conn._client.post(
|
||||||
f"/v1/table/{self._name}/index/{index_uuid}/stats/"
|
f"/v1/table/{self._name}/index/{index_uuid}/stats/"
|
||||||
)
|
)
|
||||||
@@ -485,64 +485,6 @@ class RemoteTable(Table):
|
|||||||
|
|
||||||
payload = {"predicate": where, "updates": updates}
|
payload = {"predicate": where, "updates": updates}
|
||||||
self._conn._client.post(f"/v1/table/{self._name}/update/", data=payload)
|
self._conn._client.post(f"/v1/table/{self._name}/update/", data=payload)
|
||||||
|
|
||||||
def checkout(self, version: int):
|
|
||||||
"""Checkout a version of the table. This is an in-place operation.
|
|
||||||
|
|
||||||
This allows viewing previous versions of the table. If you wish to
|
|
||||||
keep writing to the dataset starting from an old version, then use
|
|
||||||
the `restore` function.
|
|
||||||
|
|
||||||
Calling this method will set the table into time-travel mode. If you
|
|
||||||
wish to return to standard mode, call `checkout_latest`.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
version : int
|
|
||||||
The version to checkout.
|
|
||||||
|
|
||||||
Examples ??? to be changed
|
|
||||||
--------
|
|
||||||
>>> import lancedb
|
|
||||||
>>> data = [{"vector": [1.1, 0.9], "type": "vector"}]
|
|
||||||
>>> db = lancedb.connect("db://...", api_key="...", # doctest: +SKIP
|
|
||||||
... region="...") # doctest: +SKIP
|
|
||||||
>>> table = db.create_table("my_table", data) # doctest: +SKIP
|
|
||||||
>>> table.version
|
|
||||||
2
|
|
||||||
>>> table.to_pandas()
|
|
||||||
vector type
|
|
||||||
0 [1.1, 0.9] vector
|
|
||||||
>>> table.add([{"vector": [0.5, 0.2], "type": "vector"}])
|
|
||||||
>>> table.version
|
|
||||||
3
|
|
||||||
>>> table.checkout(2)
|
|
||||||
>>> table.to_pandas()
|
|
||||||
vector type
|
|
||||||
0 [1.1, 0.9] vector
|
|
||||||
"""
|
|
||||||
|
|
||||||
def checkout_latest(self):
|
|
||||||
"""checkout_latest() is not yet supported on LanceDB cloud"""
|
|
||||||
raise NotImplementedError("checkout_latest() is not yet supported on LanceDB cloud")
|
|
||||||
|
|
||||||
def restore(self, version: int = None):
|
|
||||||
"""Restore a version of the table. This is an in-place operation.
|
|
||||||
|
|
||||||
This creates a new version where the data is equivalent to the
|
|
||||||
specified previous version. Data is not copied (as of python-v0.2.1).
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
version : int, default None
|
|
||||||
The version to restore. If unspecified then restores the currently
|
|
||||||
checked out version. If the currently checked out version is the
|
|
||||||
latest version then this is a no-op.
|
|
||||||
Examples
|
|
||||||
--------
|
|
||||||
>>> import lancedb
|
|
||||||
"""
|
|
||||||
max_version =
|
|
||||||
|
|
||||||
def cleanup_old_versions(self, *_):
|
def cleanup_old_versions(self, *_):
|
||||||
"""cleanup_old_versions() is not supported on the LanceDB cloud"""
|
"""cleanup_old_versions() is not supported on the LanceDB cloud"""
|
||||||
|
|||||||
@@ -46,10 +46,18 @@ impl VectorIndex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct VectorIndexMetadata {
|
||||||
|
pub metric_type: String,
|
||||||
|
pub index_type: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct VectorIndexStatistics {
|
pub struct VectorIndexStatistics {
|
||||||
pub num_indexed_rows: usize,
|
pub num_indexed_rows: usize,
|
||||||
pub num_unindexed_rows: usize,
|
pub num_unindexed_rows: usize,
|
||||||
|
pub index_type: String,
|
||||||
|
pub indices: Vec<VectorIndexMetadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builder for an IVF PQ index.
|
/// Builder for an IVF PQ index.
|
||||||
|
|||||||
@@ -1061,6 +1061,26 @@ impl NativeTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_index_type(&self, index_uuid: &str) -> Result<Option<String>> {
|
||||||
|
match self.load_index_stats(index_uuid).await? {
|
||||||
|
Some(stats) => Ok(Some(stats.index_type)),
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_distance_type(&self, index_uuid: &str) -> Result<Option<String>> {
|
||||||
|
match self.load_index_stats(index_uuid).await? {
|
||||||
|
Some(stats) => Ok(Some(
|
||||||
|
stats
|
||||||
|
.indices
|
||||||
|
.iter()
|
||||||
|
.map(|i| i.metric_type.clone())
|
||||||
|
.collect(),
|
||||||
|
)),
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn load_indices(&self) -> Result<Vec<VectorIndex>> {
|
pub async fn load_indices(&self) -> Result<Vec<VectorIndex>> {
|
||||||
let dataset = self.dataset.get().await?;
|
let dataset = self.dataset.get().await?;
|
||||||
let (indices, mf) = futures::try_join!(dataset.load_indices(), dataset.latest_manifest())?;
|
let (indices, mf) = futures::try_join!(dataset.load_indices(), dataset.latest_manifest())?;
|
||||||
|
|||||||
Reference in New Issue
Block a user