Skip to content

Commit

Permalink
use list fields wherever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
brimoor committed Dec 21, 2024
1 parent b5a1aab commit b59bcee
Show file tree
Hide file tree
Showing 3 changed files with 373 additions and 279 deletions.
4 changes: 2 additions & 2 deletions fiftyone/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1944,8 +1944,8 @@ def _populate_summary_field(self, field_name, summary_info):
else:
_id = "_id"

if list_fields:
pipeline.append({"$unwind": "$" + list_fields[0]})
for list_field in list_fields:
pipeline.append({"$unwind": "$" + list_field})

if field_type == "categorical":
if include_counts:
Expand Down
14 changes: 14 additions & 0 deletions fiftyone/core/odm/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ def _clear_fields(cls, sample_collection, paths):
"""
is_dataset = isinstance(sample_collection, fod.Dataset)

paths = _remove_nested_paths(paths)

simple_paths = []
coll_paths = []

Expand Down Expand Up @@ -716,6 +718,8 @@ def _delete_fields(cls, paths, error_level=0):
media_type = dataset.media_type
is_frame_field = cls._is_frames_doc

paths = _remove_nested_paths(paths)

del_paths = []
del_schema_paths = []

Expand Down Expand Up @@ -819,6 +823,8 @@ def _remove_dynamic_fields(cls, paths, error_level=0):
dataset = cls._dataset
dataset_doc = dataset._doc

paths = _remove_nested_paths(paths)

del_paths = []

for path in paths:
Expand Down Expand Up @@ -1863,6 +1869,14 @@ def _split_path(path):
return chunks[0], chunks[1]


def _remove_nested_paths(paths):
return [
path
for path in paths
if not any(path.startswith(p + ".") for p in paths)
]


def _add_field_doc(field_docs, root_doc, field_or_doc):
if isinstance(field_or_doc, fof.Field):
new_field_doc = SampleFieldDocument.from_field(field_or_doc)
Expand Down
Loading

0 comments on commit b59bcee

Please sign in to comment.