From cea9b9a61f1305e33648ef1dd0c4a791f3c4b721 Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Mon, 2 Dec 2024 19:40:49 -0500 Subject: [PATCH] omit slice filter for frame collection queries (#5207) --- fiftyone/server/lightning.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/fiftyone/server/lightning.py b/fiftyone/server/lightning.py index 9eeed0acb4..b29ba82b52 100644 --- a/fiftyone/server/lightning.py +++ b/fiftyone/server/lightning.py @@ -127,7 +127,7 @@ async def lightning_resolver( input: LightningInput, info: Info ) -> t.List[LightningResults]: dataset: fo.Dataset = fo.load_dataset(input.dataset) - collections, queries, resolvers = zip( + collections, queries, resolvers, is_frames = zip( *[ _resolve_lightning_path_queries(path, dataset, info) for path in input.paths @@ -135,8 +135,10 @@ async def lightning_resolver( ) counts = [len(a) for a in queries] flattened = [ - (collection, item) - for collection, sublist in zip(collections, queries) + (collection, item, is_frames) + for collection, sublist, is_frames in zip( + collections, queries, is_frames + ) for item in sublist ] @@ -211,7 +213,7 @@ def _resolve_bool(results): true=bool(true), ) - return collection, queries, _resolve_bool + return collection, queries, _resolve_bool, is_frame_field if meets_type(field, (fof.DateField, fof.DateTimeField, fof.IntField)): queries = [ @@ -229,7 +231,7 @@ def _resolve_int(results): none=bool(none), ) - return collection, queries, _resolve_int + return collection, queries, _resolve_int, is_frame_field if meets_type(field, fof.FloatField): queries = [ @@ -258,7 +260,7 @@ def _resolve_float(results): none=none, ) - return collection, queries, _resolve_float + return collection, queries, _resolve_float, is_frame_field if meets_type(field, fof.ObjectIdField): @@ -274,6 +276,7 @@ def _resolve_object_id(results): collection, [DistinctQuery(**d)], _resolve_object_id, + is_frame_field, ) if meets_type(field, fof.StringField): @@ -290,6 +293,7 @@ def _resolve_string(results): collection, [DistinctQuery(**d)], _resolve_string, + is_frame_field, ) raise ValueError(f"cannot resolve {path.path}: {field} is not supported") @@ -298,14 +302,20 @@ def _resolve_string(results): async def _do_async_pooled_queries( dataset: fo.Dataset, queries: t.List[ - t.Tuple[AsyncIOMotorCollection, t.Union[DistinctQuery, t.List[t.Dict]]] + t.Tuple[ + AsyncIOMotorCollection, + t.Union[DistinctQuery, t.List[t.Dict]], + bool, + ] ], filter: t.Optional[t.Mapping[str, str]], ): return await asyncio.gather( *[ - _do_async_query(dataset, collection, query, filter) - for collection, query in queries + _do_async_query( + dataset, collection, query, None if is_frames else filter + ) + for collection, query, is_frames in queries ] )