Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit slice filter for frame collection QP #5207

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading