mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
refactor(memory): keep HNSWVectorIndex.set_ef_search un-deprecated
Review pointed out that MemoryConfig.hnsw_ef_search and the ef_search constructor argument only set ef at build time; nothing replaces tuning a live index. Drop the deprecation and its test. count_sync stays deprecated: count(MemoryFilter( include_superseded=True)) runs the same unfiltered COUNT(*). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
da1c239ddf
commit
0d4286df85
@@ -15,7 +15,6 @@ from __future__ import annotations
|
||||
|
||||
import heapq
|
||||
import json
|
||||
import warnings
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -1033,20 +1032,9 @@ class HNSWVectorIndex:
|
||||
|
||||
Higher values give better recall but slower search.
|
||||
|
||||
.. deprecated::
|
||||
Nothing in Headroom calls this. Set ``MemoryConfig.hnsw_ef_search``
|
||||
(or the ``ef_search`` constructor argument) instead.
|
||||
|
||||
Args:
|
||||
ef_search: New ef_search value.
|
||||
"""
|
||||
warnings.warn(
|
||||
"HNSWVectorIndex.set_ef_search is deprecated and will be removed in a future "
|
||||
"release; set MemoryConfig.hnsw_ef_search (or the ef_search constructor "
|
||||
"argument) instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
with self._lock:
|
||||
self._ef_search = ef_search
|
||||
self._index.set_ef(ef_search)
|
||||
|
||||
@@ -13,14 +13,3 @@ def test_count_sync_warns_deprecated(tmp_path: Path) -> None:
|
||||
store = SQLiteMemoryStore(str(tmp_path / "mem.db"))
|
||||
with pytest.warns(DeprecationWarning, match="SQLiteMemoryStore.count_sync is deprecated"):
|
||||
assert store.count_sync() == 0
|
||||
|
||||
|
||||
def test_set_ef_search_warns_deprecated() -> None:
|
||||
from headroom.memory.adapters.hnsw import HNSWVectorIndex, _check_hnswlib_available
|
||||
|
||||
if not _check_hnswlib_available():
|
||||
pytest.skip("hnswlib not installed")
|
||||
index = HNSWVectorIndex(dimension=8)
|
||||
with pytest.warns(DeprecationWarning, match="HNSWVectorIndex.set_ef_search is deprecated"):
|
||||
index.set_ef_search(64)
|
||||
assert index._ef_search == 64
|
||||
|
||||
Reference in New Issue
Block a user