Skip to content

Commit

Permalink
Addressed feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
minhtuevo committed Aug 20, 2024
1 parent 8e83944 commit 9a1654b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
9 changes: 3 additions & 6 deletions fiftyone/core/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -9126,9 +9126,7 @@ def get_index_information(self, include_stats=False):

return index_info

def create_index(
self, field_or_spec, unique=False, acknowledged=True, **kwargs
):
def create_index(self, field_or_spec, unique=False, wait=True, **kwargs):
"""Creates an index on the given field or with the given specification,
if necessary.
Expand Down Expand Up @@ -9162,8 +9160,7 @@ def create_index(
:meth:`pymongo:pymongo.collection.Collection.create_index` for
supported values
unique (False): whether to add a uniqueness constraint to the index
acknowledged (True): whether to wait and acknowledge index
creation
wait (True): whether to wait for index creation to finish
**kwargs: optional keyword arguments for
:meth:`pymongo:pymongo.collection.Collection.create_index`
Expand Down Expand Up @@ -9243,7 +9240,7 @@ def create_index(
return index_name

# Setting `w=0` sets `acknowledged=False` in pymongo
write_concern = WriteConcern(w=0) if not acknowledged else None
write_concern = None if wait else WriteConcern(w=0)

if is_frame_index:
coll = self._dataset._get_frame_collection(
Expand Down
12 changes: 4 additions & 8 deletions fiftyone/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
ReplaceOne,
UpdateMany,
UpdateOne,
WriteConcern,
)
from pymongo.collection import Collection
from pymongo.errors import CursorNotFound, BulkWriteError
Expand Down Expand Up @@ -330,7 +329,6 @@ def __init__(
self._run_cache = cachetools.LRUCache(5)

self._deleted = False
self._write_concern = None

if not _virtual:
self._update_last_loaded_at()
Expand Down Expand Up @@ -1184,7 +1182,6 @@ def _sample_collstats(self):
return conn.command(
"collstats",
self._sample_collection_name,
write_concern=self._write_concern,
)

def _frame_collstats(self):
Expand All @@ -1195,7 +1192,6 @@ def _frame_collstats(self):
return conn.command(
"collstats",
self._frame_collection_name,
write_concern=self._write_concern,
)

def first(self):
Expand Down Expand Up @@ -7040,9 +7036,9 @@ def _sample_collection_name(self):

@property
def _sample_collection(self):
return self._get_sample_collection(write_concern=self._write_concern)
return self._get_sample_collection()

def _get_sample_collection(self, write_concern=None) -> Collection:
def _get_sample_collection(self, write_concern=None):
return foo.get_db_conn().get_collection(
self._sample_collection_name, write_concern=write_concern
)
Expand All @@ -7053,9 +7049,9 @@ def _frame_collection_name(self):

@property
def _frame_collection(self):
return self._get_frame_collection(write_concern=self._write_concern)
return self._get_frame_collection()

def _get_frame_collection(self, write_concern=None) -> Collection:
def _get_frame_collection(self, write_concern=None):
if self._frame_collection_name is None:
return None

Expand Down

0 comments on commit 9a1654b

Please sign in to comment.