hnswlib
hnswlib copied to clipboard
stream load. Is it possible?
I want to load network resourse to index but it failed
import requests
import io
import pickle
import hnswlib
def get_stream(url):
response = requests.get(url)
stream_data = response.content
return io.BytesIO(stream_data)
model = pickle.load(get_stream('http://example.com/model')) # it works
index = hnswlib.Index(space='cosine', dim=128)
index.load_index(get_stream('http://example.com/index.hnsw')) # doesn't work
got error
TypeError: load_index(): incompatible function arguments. The following argument types are supported:
1. (self: hnswlib.Index, path_to_index: str, max_elements: int = 0, allow_replace_deleted: bool = False) -> None
Invoked with: <hnswlib.Index(space='cosine', dim=128)>, <_io.BytesIO object at 0x7fd364e557c0>
Is it normal idea?