Skip to content

Commit

Permalink
use default_group_slice
Browse files Browse the repository at this point in the history
  • Loading branch information
brimoor committed Sep 25, 2024
1 parent fc22e3a commit cbb8b15
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
5 changes: 4 additions & 1 deletion fiftyone/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,10 @@ def group_slice(self, slice_name):
if slice_name is None:
slice_name = self._doc.default_group_slice

if slice_name not in self._doc.group_media_types:
if (
slice_name is not None
and slice_name not in self._doc.group_media_types
):
raise ValueError("Dataset has no group slice '%s'" % slice_name)

self._group_slice = slice_name
Expand Down
21 changes: 10 additions & 11 deletions fiftyone/operators/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,11 @@ def execute(self, ctx):
new_name = ctx.params["new_name"]

ctx.dataset.rename_group_slice(name, new_name)
ctx.ops.set_group_slice(new_name)

# @todo ideally we would only set this if the group slice we renamed is
# currently loaded in the App
ctx.ops.set_group_slice(ctx.dataset.default_group_slice)

ctx.ops.reload_dataset()


Expand Down Expand Up @@ -1565,16 +1569,11 @@ def execute(self, ctx):
name = ctx.params["name"]

ctx.dataset.delete_group_slice(name)
group_slices = ctx.dataset.group_slices
selected_group_slice = next(
(
group_slice
for group_slice in group_slices
if group_slice != name
),
None,
)
ctx.ops.set_group_slice(selected_group_slice)

# @todo ideally we would only set this if the group slice we deleted is
# currently loaded in the App
ctx.ops.set_group_slice(ctx.dataset.default_group_slice)

ctx.ops.reload_dataset()


Expand Down
4 changes: 2 additions & 2 deletions fiftyone/operators/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,10 @@ def set_panel_title(self, id=None, title=None):
)

def set_group_slice(self, slice):
"""Set the group slices in the App.
"""Set the active group slice in the App.
Args:
slice: the group slice to set
slice: the group slice to activate
"""
return self._ctx.trigger("set_group_slice", {"slice": slice})

Expand Down

0 comments on commit cbb8b15

Please sign in to comment.