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 42 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bb7c2d3
add default_visibility_labels to dataset app config
sashankaryal Dec 3, 2024
f1e2e2b
update gql for new app config
sashankaryal Dec 3, 2024
8fbb996
add selector for default visibility labels
sashankaryal Dec 3, 2024
7053913
add function to get dense labels list
sashankaryal Dec 5, 2024
0906eb5
new hook for setting sidebar labels
sashankaryal Dec 5, 2024
64be7ba
update _activeFields to respect default labels from app config (pendi…
sashankaryal Dec 6, 2024
dd75737
move color resolver to another module
sashankaryal Dec 6, 2024
26c5d54
remove unused indexed png decoder code
sashankaryal Dec 6, 2024
f90ac62
add .env to gitignore
sashankaryal Dec 20, 2024
df97641
don't process overlays if path is there but overlay not decoded
sashankaryal Dec 20, 2024
4897a18
pass activepaths to worker
sashankaryal Jan 6, 2025
f373f81
add refreshSample
sashankaryal Jan 6, 2025
3621c64
add render status
sashankaryal Jan 6, 2025
42ab846
remove redundant guard
sashankaryal Jan 6, 2025
3eecb35
refresh layout when sidebar is updated
sashankaryal Jan 6, 2025
441d567
remove decodeLabelOverlay
sashankaryal Jan 6, 2025
612c851
fix modal
sashankaryal Jan 7, 2025
a89fc2f
better name
sashankaryal Jan 7, 2025
33ec52b
Remove unnecessary log
sashankaryal Jan 7, 2025
6f9685a
retry update sample
sashankaryal Jan 7, 2025
5cb4e08
add painting status
sashankaryal Jan 7, 2025
1f84a8c
add guard in painting loop
sashankaryal Jan 8, 2025
a037899
use local recoil state
sashankaryal Jan 8, 2025
178edac
remove fix me guard
sashankaryal Jan 8, 2025
e992dec
use lru cache in color resolver
sashankaryal Jan 8, 2025
ddb02c7
add null check in visibility labels selector
sashankaryal Jan 9, 2025
397b30e
sample id fallback to _id
sashankaryal Jan 9, 2025
3630c8a
sample id fallback to _id
sashankaryal Jan 9, 2025
9085730
pass activepaths in frames
sashankaryal Jan 9, 2025
e821100
explicit type for lru color cache
sashankaryal Jan 9, 2025
52566d5
fix cache
sashankaryal Jan 9, 2025
bec2ada
impl default visibility for frames
sashankaryal Jan 10, 2025
f784ba3
add sample guard in refreshSample
sashankaryal Jan 11, 2025
a858ddf
use more granular strategy for caching
sashankaryal Jan 11, 2025
84029f7
move sync and check logic to another file and add unit tests
sashankaryal Jan 11, 2025
b7ac893
remove debug log
sashankaryal Jan 11, 2025
6d99046
fix modal
sashankaryal Jan 11, 2025
e7467cb
don't show qp toast and analytics in testing
sashankaryal Jan 14, 2025
7a2a99a
enable ground truth in sidebar tests
sashankaryal Jan 14, 2025
9eeac97
enable ground truth and predictions in tagger e2e test
sashankaryal Jan 14, 2025
5919203
unit test default visible labels computation
sashankaryal Jan 14, 2025
1a7026f
ignore useLiteralKeys
sashankaryal Jan 14, 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
10 changes: 10 additions & 0 deletions app/packages/app/src/components/Analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,15 @@ export default function Analytics({ fragment }: { fragment: Analytics$key }) {
);
const callGA = useCallGA(info);

// NOTE: this is a one-off case where we disable the component in playwright
// so that this banner doesn't interfere with the tests.
// waiting for analytics to show up before we can dismiss it is a pain
// and adds significant time to the tests.
// we should usually _never_ have any divergence between tests and prod.
if (window["IS_PLAYWRIGHT"]) {
console.log("Analytics component is disabled in playwright");
return null;
}

return <AnalyticsConsent callGA={callGA} info={info} />;
}

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
Loading
Loading