Skip to content

Commit

Permalink
omit slice filter for frame collection queries
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Dec 3, 2024
1 parent bf1d29d commit b06716a
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions fiftyone/server/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,18 @@ 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
]
)
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
]

Expand Down Expand Up @@ -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 = [
Expand All @@ -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 = [
Expand Down Expand Up @@ -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):

Expand All @@ -274,6 +276,7 @@ def _resolve_object_id(results):
collection,
[DistinctQuery(**d)],
_resolve_object_id,
is_frame_field,
)

if meets_type(field, fof.StringField):
Expand All @@ -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")
Expand All @@ -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
]
)

Expand Down

0 comments on commit b06716a

Please sign in to comment.