Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default labels visibility in dataset app config + selective labels rendering optimization #5356

Open
wants to merge 37 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ff35f5b
add default_visibility_labels to dataset app config
sashankaryal Dec 3, 2024
0c8bd80
update gql for new app config
sashankaryal Dec 3, 2024
89c4881
add selector for default visibility labels
sashankaryal Dec 3, 2024
f2083cf
add function to get dense labels list
sashankaryal Dec 5, 2024
42da2fb
new hook for setting sidebar labels
sashankaryal Dec 5, 2024
6f05c81
update _activeFields to respect default labels from app config (pendi…
sashankaryal Dec 6, 2024
cab1d36
move color resolver to another module
sashankaryal Dec 6, 2024
9c057a7
remove unused indexed png decoder code
sashankaryal Dec 6, 2024
6d97b2d
add .env to gitignore
sashankaryal Dec 20, 2024
1209894
don't process overlays if path is there but overlay not decoded
sashankaryal Dec 20, 2024
172b8fb
pass activepaths to worker
sashankaryal Jan 6, 2025
60eb8fd
add refreshSample
sashankaryal Jan 6, 2025
a939033
add render status
sashankaryal Jan 6, 2025
2aa368b
remove redundant guard
sashankaryal Jan 6, 2025
dd869cc
refresh layout when sidebar is updated
sashankaryal Jan 6, 2025
2c40804
remove decodeLabelOverlay
sashankaryal Jan 6, 2025
90d8066
fix modal
sashankaryal Jan 7, 2025
a3f376b
better name
sashankaryal Jan 7, 2025
c1a046d
Remove unnecessary log
sashankaryal Jan 7, 2025
419b02b
retry update sample
sashankaryal Jan 7, 2025
5e85c2b
add painting status
sashankaryal Jan 7, 2025
3c87042
add guard in painting loop
sashankaryal Jan 8, 2025
c88993f
use local recoil state
sashankaryal Jan 8, 2025
2b13086
remove fix me guard
sashankaryal Jan 8, 2025
7b80b33
use lru cache in color resolver
sashankaryal Jan 8, 2025
9cd399a
add null check in visibility labels selector
sashankaryal Jan 9, 2025
c530a70
sample id fallback to _id
sashankaryal Jan 9, 2025
b41bc3f
sample id fallback to _id
sashankaryal Jan 9, 2025
65a553b
pass activepaths in frames
sashankaryal Jan 9, 2025
767a32e
explicit type for lru color cache
sashankaryal Jan 9, 2025
1c8d400
fix cache
sashankaryal Jan 9, 2025
c37a843
impl default visibility for frames
sashankaryal Jan 10, 2025
ebd99ae
add sample guard in refreshSample
sashankaryal Jan 11, 2025
3975c8b
use more granular strategy for caching
sashankaryal Jan 11, 2025
4630ad4
move sync and check logic to another file and add unit tests
sashankaryal Jan 11, 2025
acbf069
remove debug log
sashankaryal Jan 11, 2025
d8ecb44
fix modal
sashankaryal Jan 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ dist/
coverage.xml
.coverage.*
pyvenv.cfg

.env

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/packages/core/src/components/Dataset.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useTrackEvent } from "@fiftyone/analytics";
import { subscribe } from "@fiftyone/relay";
import { isModalActive } from "@fiftyone/state";
import React, { useEffect } from "react";
import { useRecoilValue } from "recoil";
import styled from "styled-components";
import ColorModal from "./ColorModal/ColorModal";
import { activeColorEntry } from "./ColorModal/state";
import EventTracker from "./EventTracker";
import Modal from "./Modal";
import SamplesContainer from "./SamplesContainer";
import EventTracker from "./EventTracker";
import { useTrackEvent } from "@fiftyone/analytics";

const Container = styled.div`
height: 100%;
Expand Down
25 changes: 24 additions & 1 deletion app/packages/core/src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import React, {
useRef,
useState,
} from "react";
import { useRecoilValue } from "recoil";
import { useRecoilCallback, useRecoilValue } from "recoil";
import { v4 as uuid } from "uuid";
import { QP_WAIT, QueryPerformanceToastEvent } from "../QueryPerformanceToast";
import { gridActivePathsLUT } from "../Sidebar/useShouldReloadSample";
import { gridCrop, gridSpacing, pageParameters } from "./recoil";
import useAt from "./useAt";
import useEscape from "./useEscape";
Expand Down Expand Up @@ -46,6 +47,15 @@ function Grid() {
const setSample = fos.useExpandSample(store);
const getFontSize = useFontSize(id);

const getCurrentActiveLabelFields = useRecoilCallback(
({ snapshot }) =>
() => {
return snapshot
.getLoadable(fos.activeLabelFields({ modal: false }))
.getValue();
}
);

const spotlight = useMemo(() => {
/** SPOTLIGHT REFRESHER */
reset;
Expand All @@ -61,6 +71,7 @@ function Grid() {
const looker = lookerStore.get(id.description);
looker?.destroy();
lookerStore.delete(id.description);
gridActivePathsLUT.delete(id.description);
},
detach: (id) => {
const looker = lookerStore.get(id.description);
Expand Down Expand Up @@ -101,6 +112,18 @@ function Grid() {
);
lookerStore.set(id.description, looker);
looker.attach(element, dimensions);

// initialize active paths tracker
const currentActiveLabelFields = getCurrentActiveLabelFields();
if (
currentActiveLabelFields &&
!gridActivePathsLUT.has(id.description)
) {
gridActivePathsLUT.set(
id.description,
new Set(currentActiveLabelFields)
);
}
},
scrollbar: true,
spacing,
Expand Down
28 changes: 16 additions & 12 deletions app/packages/core/src/components/Grid/useRefreshers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LRUCache } from "lru-cache";
import { useEffect, useMemo } from "react";
import uuid from "react-uuid";
import { useRecoilValue } from "recoil";
import { gridActivePathsLUT } from "../Sidebar/useShouldReloadSample";
import { gridAt, gridOffset, gridPage } from "./recoil";

const MAX_LRU_CACHE_ITEMS = 510;
Expand Down Expand Up @@ -64,27 +65,30 @@ export default function useRefreshers() {
return uuid();
}, [layoutReset, pageReset]);

useEffect(
() =>
subscribe(({ event }, { reset }) => {
if (event === "fieldVisibility") return;
useEffect(() => {
const unsubscribe = subscribe(({ event }, { reset }) => {
if (event === "fieldVisibility") return;

// if not a modal page change, reset the grid location
reset(gridAt);
reset(gridPage);
reset(gridOffset);
}),
[]
);
// if not a modal page change, reset the grid location
reset(gridAt);
reset(gridPage);
reset(gridOffset);
});

return () => {
unsubscribe();
};
}, []);

const lookerStore = useMemo(() => {
/** LOOKER STORE REFRESHER */
reset;
/** LOOKER STORE REFRESHER */

return new LRUCache<string, fos.Lookers>({
dispose: (looker) => {
dispose: (looker, id) => {
looker.destroy();
gridActivePathsLUT.delete(id);
},
max: MAX_LRU_CACHE_ITEMS,
noDisposeOnSet: true,
Expand Down
10 changes: 10 additions & 0 deletions app/packages/core/src/components/Grid/useSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as fos from "@fiftyone/state";
import type { LRUCache } from "lru-cache";
import { useEffect } from "react";
import { useRecoilValue } from "recoil";
import { useShouldReloadSampleOnActiveFieldsChange } from "../Sidebar/useShouldReloadSample";

export default function useSelect(
getFontSize: () => number,
Expand All @@ -12,6 +13,10 @@ export default function useSelect(
) {
const { init, deferred } = fos.useDeferrer();

const shouldRefresh = useShouldReloadSampleOnActiveFieldsChange({
modal: false,
});

const selected = useRecoilValue(fos.selectedSamples);
useEffect(() => {
deferred(() => {
Expand All @@ -29,6 +34,11 @@ export default function useSelect(
fontSize,
selected: selected.has(id.description),
});

// rerender looker if active fields have changed and have never been rendered before
if (shouldRefresh(id.description)) {
instance.refreshSample();
}
});

for (const id of store.keys()) {
Expand Down
Loading
Loading