Skip to content

Commit

Permalink
use view if possible, avoid len() call
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed May 28, 2024
1 parent e983f0e commit ec8d594
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion fiftyone/core/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def __init__(
view_name=final_view_name,
spaces=spaces,
color_scheme=build_color_scheme(color_scheme, dataset, config),
group_slice=(dataset.group_slice if dataset else None),
group_slice=_pull_group_slice(dataset, view),
)
self._client = fosc.Client(
address=address,
Expand Down Expand Up @@ -1317,3 +1317,15 @@ def _on_refresh(session: Session, state: t.Optional[StateDescription]):

if session.dataset is not None:
session.dataset.reload()


def _pull_group_slice(
dataset: t.Optional[fod.Dataset], view: t.Optional[fov.DatasetView]
) -> t.Union[None, str]:
if view is not None:
return view.group_slice

if dataset is not None:
return dataset.group_slice

return None

0 comments on commit ec8d594

Please sign in to comment.