Skip to content

Commit fe8c270

Browse files
committed
fix: move mutable class attrs to __init__ in FaissOnlineStore
Signed-off-by: RutujaPathade <73137503+RutujaPathade@users.noreply.github.com>
1 parent c38454a commit fe8c270

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

sdk/python/feast/infra/online_stores/faiss_online_store.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ def __init__(self):
6666
self._in_memory_stores: Dict[str, InMemoryStore] = {}
6767
self._config: Optional[FaissOnlineStoreConfig] = None
6868

69-
def _get_index(
70-
self, table_key: str
71-
) -> Optional[faiss.IndexIVFFlat]:
69+
def _get_index(self, table_key: str) -> Optional[faiss.IndexIVFFlat]:
7270
return self._indices.get(table_key)
7371

7472
def update(
@@ -95,9 +93,7 @@ def update(
9593

9694
if table_key not in self._indices or not partial:
9795
quantizer = faiss.IndexFlatL2(dimension)
98-
index = faiss.IndexIVFFlat(
99-
quantizer, dimension, self._config.nlist
100-
)
96+
index = faiss.IndexIVFFlat(quantizer, dimension, self._config.nlist)
10197
index.train(
10298
np.random.rand(self._config.nlist * 100, dimension).astype(
10399
np.float32
@@ -202,13 +198,9 @@ def online_write_batch(
202198
]
203199
mask = np.array(existing_indices) != -1
204200
if np.any(mask):
205-
index.remove_ids(
206-
np.array([idx for idx in existing_indices if idx != -1])
207-
)
201+
index.remove_ids(np.array([idx for idx in existing_indices if idx != -1]))
208202

209-
new_indices = np.arange(
210-
index.ntotal, index.ntotal + len(feature_vectors_array)
211-
)
203+
new_indices = np.arange(index.ntotal, index.ntotal + len(feature_vectors_array))
212204
index.add(feature_vectors_array)
213205

214206
for sk, idx in zip(serialized_keys, new_indices):

0 commit comments

Comments
 (0)