nmslib / hnswlib

Header-only C++/python library for fast approximate nearest neighbors

Home Page:https://github.com/nmslib/hnswlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: type object 'hnswlib.Index' has no attribute 'file_handle_count'

rtayeb opened this issue · comments

my env
Linux mint 21
Python 3.10.11

Running the following 2 lines of code generates error:

import chromadb
client = chromadb.PersistentClient(path="./tmp_dir")

generates the following error
AttributeError: type object 'hnswlib.Index' has no attribute 'file_handle_count'

here is the full error report

AttributeError Traceback (most recent call last)
Cell In[2], line 7
2 import chromadb
4 # You can configure Chroma to save and load from your local machine.
5 # Data will be persisted automatically and loaded on start (if it exists).
----> 7 client = chromadb.PersistentClient(path="/home/reza/junkd")

File ~/anaconda3/envs/torch1b/lib/python3.10/site-packages/chromadb/init.py:73, in PersistentClient(path, settings)
70 settings.persist_directory = path
71 settings.is_persistent = True
---> 73 return Client(settings)

File ~/anaconda3/envs/torch1b/lib/python3.10/site-packages/chromadb/init.py:110, in Client(settings)
107 system = System(settings)
109 telemetry_client = system.instance(Telemetry)
--> 110 api = system.instance(API)
112 system.start()
114 # Submit event for client start

File ~/anaconda3/envs/torch1b/lib/python3.10/site-packages/chromadb/config.py:195, in System.instance(self, type)
192 type = get_class(fqn, type)
194 if type not in self._instances:
--> 195 impl = type(self)
196 self._instances[type] = impl
197 if self._running:

File ~/anaconda3/envs/torch1b/lib/python3.10/site-packages/chromadb/api/segment.py:82, in SegmentAPI.init(self, system)
80 self._settings = system.settings
81 self._sysdb = self.require(SysDB)
---> 82 self._manager = self.require(SegmentManager)
83 self._telemetry_client = self.require(Telemetry)
84 self._producer = self.require(Producer)

File ~/anaconda3/envs/torch1b/lib/python3.10/site-packages/chromadb/config.py:134, in Component.require(self, type)
131 def require(self, type: Type[T]) -> T:
132 """Get a Component instance of the given type, and register as a dependency of
133 that instance."""
--> 134 inst = self._system.instance(type)
135 self._dependencies.add(inst)
136 return inst

File ~/anaconda3/envs/torch1b/lib/python3.10/site-packages/chromadb/config.py:195, in System.instance(self, type)
192 type = get_class(fqn, type)
194 if type not in self._instances:
--> 195 impl = type(self)
196 self._instances[type] = impl
197 if self._running:

File ~/anaconda3/envs/torch1b/lib/python3.10/site-packages/chromadb/segment/impl/manager/local.py:73, in LocalSegmentManager.init(self, system)
69 else:
70 self._max_file_handles = ctypes.windll.msvcrt._getmaxstdio() # type: ignore
71 segment_limit = (
72 self._max_file_handles
---> 73 // PersistentLocalHnswSegment.get_file_handle_count()
74 )
75 self._vector_instances_file_handle_cache = LRUCache(
76 segment_limit, callback=lambda _, v: v.close_persistent_index()
77 )

File ~/anaconda3/envs/torch1b/lib/python3.10/site-packages/chromadb/segment/impl/vector/local_persistent_hnsw.py:398, in PersistentLocalHnswSegment.get_file_handle_count()
395 @staticmethod
396 def get_file_handle_count() -> int:
397 """Return how many file handles are used by the index"""
--> 398 hnswlib_count = hnswlib.Index.file_handle_count
399 hnswlib_count = cast(int, hnswlib_count)
400 # One extra for the metadata file

AttributeError: type object 'hnswlib.Index' has no attribute 'file_handle_count'

Thanks

chroma-core/chroma#931

this fixed, this same issue for me.

Thank you