Skip to content

Commit

Permalink
Allow empty paths aggregation (#4621)
Browse files Browse the repository at this point in the history
* add no paths test

* paths fix
  • Loading branch information
benjaminpkane authored Aug 7, 2024
1 parent 62d7577 commit 11757a6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fiftyone/server/aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ async def aggregate_resolver(
if not form.dataset:
raise ValueError("Aggregate form missing dataset")

if not form.paths:
return []

view = await _load_view(form, form.slices)

slice_view = None
Expand Down
40 changes: 40 additions & 0 deletions tests/unittests/server_aggregations_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,46 @@ class AggregationsQuery(AggregateQuery):


class TestGroupModeSidebarCounts(unittest.IsolatedAsyncioTestCase):
@drop_async_dataset
async def test_empty(self, dataset: fo.Dataset):
query = """
query Query($form: AggregationForm!) {
aggregations(form: $form) {
... on StringAggregation {
path
}
}
}
"""

result = await execute(
schema,
query,
{
"form": {
"dataset": dataset.name,
"extended_stages": {},
"filters": {},
"group_id": None,
"hidden_labels": [],
"index": 0,
"mixed": False,
"paths": [],
"sample_ids": [],
"slice": None,
"slices": None,
"view": [],
}
},
)

self.assertEqual(
result.data,
{
"aggregations": [],
},
)

@drop_async_dataset
async def test_group_mode_sidebar_counts(self, dataset: fo.Dataset):
_add_samples(dataset)
Expand Down

0 comments on commit 11757a6

Please sign in to comment.