scene_service.persistence

Scene objects in an embedded milvus-lite DB owned by the scene process.

Rows are partitioned by the map_id field, because a pose only means something in the map frame it was observed in. Each Save writes a fresh partition token (“<map_id>__s<seq>”, from map_meta) so two saves of a same-named map never mix frames; the primary key is “{partition}::{object_id}”. Each row carries a caption embedding, or a placeholder vector when no embedder is wired.

Classes

ObjectStore(db_path, *[, map_id, dim])

Latest state of each object per partition.

class scene_service.persistence.ObjectStore(db_path: str, *, map_id: str = 'default', dim: int = 512)[source]

Bases: object

Latest state of each object per partition. Synchronous: callers run it off the event loop.

close() → None[source]

Close the client and release the milvus-lite server so the next boot can reopen the same .db file.

delete_map(map_id: str) → int[source]

Delete one map’s rows; returns how many were found (capped count).

delete_object(object_id: str, *, partition: str | None = None) → bool[source]

Delete one object’s row from one partition; True when it existed.

load_all(*, partition: str | None = None, limit: int = 16384, strict: bool = False) → list[SceneObject][source]

One partition’s objects, restored as missing until re-observed.

A query error yields [] with an error log, or raises with strict (Load), where “unreadable” must not look like “empty”.

property map_id: str
persist(pairs: list[tuple[SceneObject, str | None]], *, partition: str | None = None) → int[source]

Upsert (object, caption) pairs; a None caption falls back to the label. Returns the rows written, 0 on a (logged) milvus error, so the Save path can compare it with len(pairs).

purge_live_partitions() → int[source]

Delete rows old builds left under .live* partitions; 0 on error, since cleanup must never block a boot.

set_embedder(embed_text: Callable[[list[str]], list[list[float]] | None] | None) → None[source]
scene_service.persistence.verify_local_store() → None[source]

Verify embedded storage can create and query a temporary database.