Skip to content

Commit

Permalink
Add some random to temporary small indices path (#155)
Browse files Browse the repository at this point in the history
In order to avoid failures upon concurrent executions.
Only used when `distributed = "pyspark"`

Co-authored-by: Quentin Auge <q.auge@criteo.com>
Co-authored-by: Romain Beaumont <r.beaumont@criteo.com>
  • Loading branch information
3 people authored Jan 13, 2024
1 parent a589510 commit 5391341
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions autofaiss/indices/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from tempfile import TemporaryDirectory
import tempfile
from typing import Dict, Optional, Iterator, Tuple, Callable, Any, Union, List
import uuid
from functools import partial
from multiprocessing.pool import ThreadPool

Expand Down Expand Up @@ -285,6 +286,9 @@ def add_embeddings_to_index_distributed(
index_optimizer: Optional[Callable]
The function that optimizes the index
"""
temporary_indices_folder = temporary_indices_folder.rstrip("/") + f"/{uuid.uuid4().hex}"
logger.debug(f"Will be writing temporary small indices to {temporary_indices_folder}")

temporary_indices_folder = make_path_absolute(temporary_indices_folder)
fs = _get_file_system(temporary_indices_folder)
if fs.exists(temporary_indices_folder):
Expand Down

0 comments on commit 5391341

Please sign in to comment.