From 32efaeadf1167322a48b6c5c1b38146c86d5a7a1 Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Fri, 5 May 2023 10:02:27 -0600 Subject: [PATCH 01/16] edit --- app/packages/core/src/components/Modal/Modal.tsx | 2 +- .../core/src/components/Sidebar/Entries/EntryCounts.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/packages/core/src/components/Modal/Modal.tsx b/app/packages/core/src/components/Modal/Modal.tsx index c10df66480..edd89c6a32 100644 --- a/app/packages/core/src/components/Modal/Modal.tsx +++ b/app/packages/core/src/components/Modal/Modal.tsx @@ -113,7 +113,7 @@ const SampleModal = () => { const isLabel = labelPaths.includes(entry.path); const isOther = disabled.has(entry.path); const isFieldPrimitive = - !isLabelTag && !isLabel && !isOther && !(isTag && mode === "group"); + !isLabelTag && !isLabel && !isOther && !isTag; return { children: ( <> diff --git a/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx b/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx index 30bf8502ae..d983797d41 100644 --- a/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx +++ b/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx @@ -53,11 +53,12 @@ export const PathEntryCounts = ({ if (shown.state === "hasError") { throw shown.contents; } + modal && console.log(path, shown); return shown.state === "loading" ? ( ) : ( - typeof shown.contents === "number" && ( + shown.contents && ( Date: Fri, 5 May 2023 10:06:09 -0600 Subject: [PATCH 02/16] copy --- app/packages/looker-3d/src/action-bar/SliceSelector.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx index 1a58d7057d..8fa2d9ecae 100644 --- a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx +++ b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx @@ -18,15 +18,15 @@ export const SliceSelector = () => { } if (activePcdSlices.length === 1) { - return `${activePcdSlices[0]} selected`; + return `Showing ${activePcdSlices[0]}`; } if (activePcdSlices.length === 2) { return activePcdSlices.join(" and "); } if (activePcdSlices.length === allPcdSlices.length) { - return "All pcds selected"; + return "Showing all point clouds"; } - return `${activePcdSlices.length} point-clouds selected`; + return `Showing ${activePcdSlices.length} point clouds`; }, [activePcdSlices, allPcdSlices]); const handleActionClick = useCallback(() => { @@ -43,7 +43,7 @@ export const SliceSelector = () => { return ( <> - +
{activeSlicesLabel}
From ba604ed88bdb47df0708378464e87b73798abf99 Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Fri, 5 May 2023 10:09:41 -0600 Subject: [PATCH 03/16] copy --- .../src/components/Actions/GroupMediaVisibilityContainer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/packages/core/src/components/Actions/GroupMediaVisibilityContainer.tsx b/app/packages/core/src/components/Actions/GroupMediaVisibilityContainer.tsx index da9c266d6b..434d918192 100644 --- a/app/packages/core/src/components/Actions/GroupMediaVisibilityContainer.tsx +++ b/app/packages/core/src/components/Actions/GroupMediaVisibilityContainer.tsx @@ -1,7 +1,7 @@ import { PillButton, PopoutSectionTitle } from "@fiftyone/components"; import * as fos from "@fiftyone/state"; import ViewComfyIcon from "@mui/icons-material/ViewComfy"; -import React, { useRef, useState } from "react"; +import { useRef, useState } from "react"; import useMeasure from "react-use-measure"; import { @@ -20,7 +20,7 @@ interface GroupMediaVisibilityProps { modal: boolean; } -const TITLE = "Toggle Media"; +const TITLE = "Toggle media"; const Container = styled.div` position: relative; From 3964971886b017b8fe4251cd74111dd704081982 Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Fri, 5 May 2023 10:18:24 -0600 Subject: [PATCH 04/16] rm log --- app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx b/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx index d983797d41..fdbe6e6ab6 100644 --- a/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx +++ b/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx @@ -53,7 +53,6 @@ export const PathEntryCounts = ({ if (shown.state === "hasError") { throw shown.contents; } - modal && console.log(path, shown); return shown.state === "loading" ? ( From a12f26ceb30693ac75d75e6fcf4583558fa8a739 Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Fri, 5 May 2023 15:02:29 -0600 Subject: [PATCH 05/16] wrong place --- app/packages/core/src/components/Modal/Modal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/packages/core/src/components/Modal/Modal.tsx b/app/packages/core/src/components/Modal/Modal.tsx index edd89c6a32..7d5ea0fabc 100644 --- a/app/packages/core/src/components/Modal/Modal.tsx +++ b/app/packages/core/src/components/Modal/Modal.tsx @@ -113,7 +113,7 @@ const SampleModal = () => { const isLabel = labelPaths.includes(entry.path); const isOther = disabled.has(entry.path); const isFieldPrimitive = - !isLabelTag && !isLabel && !isOther && !isTag; + !isLabelTag && !isLabel && !isOther && !(isTag && mode === "group"); return { children: ( <> @@ -132,7 +132,7 @@ const SampleModal = () => { onBlur={() => { controller.set({ zIndex: "0" }); }} - disabled={isOther || isLabelTag} + disabled={isOther || isLabelTag || isTag} key={key} trigger={trigger} /> From 635c870f1a918ec72ef3522d30470811ebc6d694 Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Fri, 5 May 2023 10:02:27 -0600 Subject: [PATCH 06/16] edit --- app/packages/core/src/components/Modal/Modal.tsx | 2 +- .../core/src/components/Sidebar/Entries/EntryCounts.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/packages/core/src/components/Modal/Modal.tsx b/app/packages/core/src/components/Modal/Modal.tsx index c10df66480..edd89c6a32 100644 --- a/app/packages/core/src/components/Modal/Modal.tsx +++ b/app/packages/core/src/components/Modal/Modal.tsx @@ -113,7 +113,7 @@ const SampleModal = () => { const isLabel = labelPaths.includes(entry.path); const isOther = disabled.has(entry.path); const isFieldPrimitive = - !isLabelTag && !isLabel && !isOther && !(isTag && mode === "group"); + !isLabelTag && !isLabel && !isOther && !isTag; return { children: ( <> diff --git a/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx b/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx index 30bf8502ae..d983797d41 100644 --- a/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx +++ b/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx @@ -53,11 +53,12 @@ export const PathEntryCounts = ({ if (shown.state === "hasError") { throw shown.contents; } + modal && console.log(path, shown); return shown.state === "loading" ? ( ) : ( - typeof shown.contents === "number" && ( + shown.contents && ( Date: Fri, 5 May 2023 10:06:09 -0600 Subject: [PATCH 07/16] copy --- app/packages/looker-3d/src/action-bar/SliceSelector.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx index 1a58d7057d..8fa2d9ecae 100644 --- a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx +++ b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx @@ -18,15 +18,15 @@ export const SliceSelector = () => { } if (activePcdSlices.length === 1) { - return `${activePcdSlices[0]} selected`; + return `Showing ${activePcdSlices[0]}`; } if (activePcdSlices.length === 2) { return activePcdSlices.join(" and "); } if (activePcdSlices.length === allPcdSlices.length) { - return "All pcds selected"; + return "Showing all point clouds"; } - return `${activePcdSlices.length} point-clouds selected`; + return `Showing ${activePcdSlices.length} point clouds`; }, [activePcdSlices, allPcdSlices]); const handleActionClick = useCallback(() => { @@ -43,7 +43,7 @@ export const SliceSelector = () => { return ( <> - +
{activeSlicesLabel}
From 69fd70fdab2d33977d8de75f63581170de2efc1a Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Fri, 5 May 2023 10:09:41 -0600 Subject: [PATCH 08/16] copy --- .../src/components/Actions/GroupMediaVisibilityContainer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/packages/core/src/components/Actions/GroupMediaVisibilityContainer.tsx b/app/packages/core/src/components/Actions/GroupMediaVisibilityContainer.tsx index da9c266d6b..434d918192 100644 --- a/app/packages/core/src/components/Actions/GroupMediaVisibilityContainer.tsx +++ b/app/packages/core/src/components/Actions/GroupMediaVisibilityContainer.tsx @@ -1,7 +1,7 @@ import { PillButton, PopoutSectionTitle } from "@fiftyone/components"; import * as fos from "@fiftyone/state"; import ViewComfyIcon from "@mui/icons-material/ViewComfy"; -import React, { useRef, useState } from "react"; +import { useRef, useState } from "react"; import useMeasure from "react-use-measure"; import { @@ -20,7 +20,7 @@ interface GroupMediaVisibilityProps { modal: boolean; } -const TITLE = "Toggle Media"; +const TITLE = "Toggle media"; const Container = styled.div` position: relative; From 483fae61525dc12a657e5eb02c24dd4fe382b7df Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Fri, 5 May 2023 10:18:24 -0600 Subject: [PATCH 09/16] rm log --- app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx b/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx index d983797d41..fdbe6e6ab6 100644 --- a/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx +++ b/app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx @@ -53,7 +53,6 @@ export const PathEntryCounts = ({ if (shown.state === "hasError") { throw shown.contents; } - modal && console.log(path, shown); return shown.state === "loading" ? ( From a37a8b5bf59059b1a36c7a3cfd3298bcd44aa853 Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Fri, 5 May 2023 15:02:29 -0600 Subject: [PATCH 10/16] wrong place --- app/packages/core/src/components/Modal/Modal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/packages/core/src/components/Modal/Modal.tsx b/app/packages/core/src/components/Modal/Modal.tsx index edd89c6a32..7d5ea0fabc 100644 --- a/app/packages/core/src/components/Modal/Modal.tsx +++ b/app/packages/core/src/components/Modal/Modal.tsx @@ -113,7 +113,7 @@ const SampleModal = () => { const isLabel = labelPaths.includes(entry.path); const isOther = disabled.has(entry.path); const isFieldPrimitive = - !isLabelTag && !isLabel && !isOther && !isTag; + !isLabelTag && !isLabel && !isOther && !(isTag && mode === "group"); return { children: ( <> @@ -132,7 +132,7 @@ const SampleModal = () => { onBlur={() => { controller.set({ zIndex: "0" }); }} - disabled={isOther || isLabelTag} + disabled={isOther || isLabelTag || isTag} key={key} trigger={trigger} /> From cc72b1397984a0d5ccc0d84558e04e40c5a96e64 Mon Sep 17 00:00:00 2001 From: Sashank Aryal Date: Mon, 8 May 2023 15:36:30 -0500 Subject: [PATCH 11/16] point clouds instead of pcds --- app/packages/looker-3d/src/action-bar/SliceSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx index 8fa2d9ecae..0febb36203 100644 --- a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx +++ b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx @@ -69,7 +69,7 @@ const PcdsSelector = () => { return ( - Select pcds + Select point clouds
{allPcdSlices.map((slice) => { return ( From 40c7b1e9e91fce45336548e5a76161c945bff80e Mon Sep 17 00:00:00 2001 From: Benjamin Kane Date: Mon, 8 May 2023 14:49:11 -0600 Subject: [PATCH 12/16] edits --- app/packages/core/src/components/Actions/utils.tsx | 2 +- app/packages/looker-3d/src/action-bar/SliceSelector.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/packages/core/src/components/Actions/utils.tsx b/app/packages/core/src/components/Actions/utils.tsx index 32b43d08ba..5db6003220 100644 --- a/app/packages/core/src/components/Actions/utils.tsx +++ b/app/packages/core/src/components/Actions/utils.tsx @@ -192,7 +192,7 @@ export const tagParameters = ({ ...params, label_fields: activeFields, target_labels: targetLabels, - slices: !groups ? [groupData?.slices] : null, + slices: !groups ? groupData?.slices : null, group_id: params.modal ? groupData?.id : null, sample_ids: getSampleIds(), labels: diff --git a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx index 8fa2d9ecae..0febb36203 100644 --- a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx +++ b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx @@ -69,7 +69,7 @@ const PcdsSelector = () => { return ( - Select pcds + Select point clouds
{allPcdSlices.map((slice) => { return ( From 34f07d2a0e90dfbf7bab45269683ac93c841fc1f Mon Sep 17 00:00:00 2001 From: brimoor Date: Tue, 9 May 2023 00:37:05 -0400 Subject: [PATCH 13/16] fixing make_optimized_view() --- fiftyone/core/view.py | 47 +++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/fiftyone/core/view.py b/fiftyone/core/view.py index 7d39c26d58..af372f3af4 100644 --- a/fiftyone/core/view.py +++ b/fiftyone/core/view.py @@ -1742,31 +1742,35 @@ def make_optimized_select_view( ordered (False): whether to sort the samples in the returned view to match the order of the provided IDs groups (False): whether the IDs are group IDs, not sample IDs - select_groups (False): whether to select sample groups via sample ids + select_groups (False): whether to select sample groups via sample IDs Returns: a :class:`DatasetView` """ - view = sample_collection.view() + in_view = sample_collection.view() + media_type = sample_collection.media_type + stages = in_view._stages - if any(isinstance(stage, fost.Mongo) for stage in view._stages): - # + if any(isinstance(stage, fost.Mongo) for stage in stages): # We have no way of knowing what a `Mongo()` stage might do, so we must # run the entire view's aggregation first and then select the samples # of interest at the end - # - if groups: - return view.select_groups(sample_ids, ordered=ordered) - elif view.media_type == fom.GROUP and not select_groups: - return view.select_group_slices(_allow_mixed=True) + view = in_view + stages = [] + else: + view = in_view._base_view + + if groups: + view = view.select_groups(sample_ids, ordered=ordered) + else: + if media_type == fom.GROUP and not select_groups: + view = view.select_group_slices(_allow_mixed=True) view = view.select(sample_ids, ordered=ordered) - if view.media_type == fom.GROUP and select_groups: + if media_type == fom.GROUP and select_groups: view = view.select_group_slices(_allow_mixed=True) - return view - # # Selecting the samples of interest first can be significantly faster than # running the entire aggregation and then selecting them. @@ -1782,24 +1786,11 @@ def make_optimized_select_view( # we'll need to account for that here... # - optimized_view = view._base_view - - if groups: - optimized_view = optimized_view.select_groups( - sample_ids, ordered=ordered - ) - else: - optimized_view = optimized_view.select(sample_ids, ordered=ordered) - if view.media_type == fom.GROUP and select_groups: - optimized_view = optimized_view.select_group_slices( - _allow_mixed=True - ) - - for stage in view._stages: + for stage in stages: if type(stage) not in fost._STAGES_THAT_SELECT_OR_REORDER: - optimized_view._stages.append(stage) + view = view._add_view_stage(stage, validate=False) - return optimized_view + return view def _filter_schema(schema, selected_fields, excluded_fields): From 2cdc36953b9671060efb51afe3eda8f0bcd58036 Mon Sep 17 00:00:00 2001 From: brimoor Date: Tue, 9 May 2023 00:49:37 -0400 Subject: [PATCH 14/16] tweaking copy --- app/packages/looker-3d/src/action-bar/SliceSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx index 0febb36203..cfc4eef664 100644 --- a/app/packages/looker-3d/src/action-bar/SliceSelector.tsx +++ b/app/packages/looker-3d/src/action-bar/SliceSelector.tsx @@ -21,7 +21,7 @@ export const SliceSelector = () => { return `Showing ${activePcdSlices[0]}`; } if (activePcdSlices.length === 2) { - return activePcdSlices.join(" and "); + return `Showing ${activePcdSlices.join(" and ")}`; } if (activePcdSlices.length === allPcdSlices.length) { return "Showing all point clouds"; From d8fcb0db25a2b61f31394bfd727e5279d4ad7612 Mon Sep 17 00:00:00 2001 From: brimoor Date: Tue, 9 May 2023 07:55:55 -0400 Subject: [PATCH 15/16] fixing regression --- fiftyone/core/view.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fiftyone/core/view.py b/fiftyone/core/view.py index af372f3af4..ffa7b3ebde 100644 --- a/fiftyone/core/view.py +++ b/fiftyone/core/view.py @@ -1763,11 +1763,7 @@ def make_optimized_select_view( if groups: view = view.select_groups(sample_ids, ordered=ordered) else: - if media_type == fom.GROUP and not select_groups: - view = view.select_group_slices(_allow_mixed=True) - view = view.select(sample_ids, ordered=ordered) - if media_type == fom.GROUP and select_groups: view = view.select_group_slices(_allow_mixed=True) From 69e1f5ef62c44761d455b5e5e096a1584d331f01 Mon Sep 17 00:00:00 2001 From: brimoor Date: Tue, 9 May 2023 08:02:16 -0400 Subject: [PATCH 16/16] removing unused parameter --- fiftyone/core/view.py | 4 --- tests/unittests/view_tests.py | 46 +++++++---------------------------- 2 files changed, 9 insertions(+), 41 deletions(-) diff --git a/fiftyone/core/view.py b/fiftyone/core/view.py index ffa7b3ebde..225f21d5dd 100644 --- a/fiftyone/core/view.py +++ b/fiftyone/core/view.py @@ -1724,7 +1724,6 @@ def make_optimized_select_view( sample_ids, ordered=False, groups=False, - select_groups=False, ): """Returns a view that selects the provided sample IDs that is optimized to reduce the document list as early as possible in the pipeline. @@ -1742,7 +1741,6 @@ def make_optimized_select_view( ordered (False): whether to sort the samples in the returned view to match the order of the provided IDs groups (False): whether the IDs are group IDs, not sample IDs - select_groups (False): whether to select sample groups via sample IDs Returns: a :class:`DatasetView` @@ -1764,8 +1762,6 @@ def make_optimized_select_view( view = view.select_groups(sample_ids, ordered=ordered) else: view = view.select(sample_ids, ordered=ordered) - if media_type == fom.GROUP and select_groups: - view = view.select_group_slices(_allow_mixed=True) # # Selecting the samples of interest first can be significantly faster than diff --git a/tests/unittests/view_tests.py b/tests/unittests/view_tests.py index b963f29135..441ba2ab85 100644 --- a/tests/unittests/view_tests.py +++ b/tests/unittests/view_tests.py @@ -3733,41 +3733,10 @@ def test_view_field_copy(self): field = F("$ground_truth") self.assertEqual(str(field), str(deepcopy(field))) - def test_make_optimized_select_view_group_media_type_select_samples(self): - samples = self._create_group_samples() - dataset = self._create_group_dataset() - sample_ids = dataset.add_samples(samples) - self.assertEqual(len(sample_ids), len(samples)) - - # Default call should have select_groups = False - optimized_view = fov.make_optimized_select_view(dataset, sample_ids[0]) - - expected_stages = [fosg.Select(sample_ids[0])] - self.assertEqual(optimized_view._all_stages, expected_stages) - - def test_make_optimized_select_view_group_media_type_select_groups(self): - samples = self._create_group_samples() - dataset = self._create_group_dataset() - sample_ids = dataset.add_samples(samples) - self.assertEqual(len(sample_ids), len(samples)) - - optimized_view = fov.make_optimized_select_view( - dataset, sample_ids[0], select_groups=True - ) - expected_stages = [ - fosg.Select(sample_ids[0]), - fosg.SelectGroupSlices(), - ] - self.assertEqual(optimized_view._all_stages, expected_stages) - - def _create_group_dataset(self): + def test_make_optimized_select_view_group_dataset(self): dataset = fo.Dataset() dataset.add_group_field("group", default="center") - self.assertEqual(dataset.media_type, fom.GROUP) - self.assertEqual(dataset.default_group_slice, "center") - return dataset - def _create_group_samples(self): groups = ["left", "center", "right"] filepaths = [ [str(i) + str(j) + ".jpg" for i in groups] for j in range(3) @@ -3777,12 +3746,15 @@ def _create_group_samples(self): samples = [] for fps in filepaths: for name, filepath in fps.items(): - sample = fo.Sample( - filepath=filepath, group=group.element(name) + samples.append( + fo.Sample(filepath=filepath, group=group.element(name)) ) - samples.append(sample) - assert all([s.group is not None for s in samples]) - return samples + + sample_ids = dataset.add_samples(samples) + + optimized_view = fov.make_optimized_select_view(dataset, sample_ids[0]) + expected_stages = [fosg.Select(sample_ids[0])] + self.assertEqual(optimized_view._all_stages, expected_stages) if __name__ == "__main__":