From dac0dfb8f97dd072a3ead3b751b057d3d8dab195 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Wed, 28 Aug 2024 16:24:41 +0530 Subject: [PATCH] Set cgroups --- web/apps/photos/src/pages/gallery/index.tsx | 13 +++++++++---- web/packages/new/photos/services/ml/index.ts | 14 ++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/web/apps/photos/src/pages/gallery/index.tsx b/web/apps/photos/src/pages/gallery/index.tsx index 04b4e611e7..adce308172 100644 --- a/web/apps/photos/src/pages/gallery/index.tsx +++ b/web/apps/photos/src/pages/gallery/index.tsx @@ -6,7 +6,10 @@ import { getLocalFiles, getLocalTrashedFiles, } from "@/new/photos/services/files"; -import { wipClusterEnable } from "@/new/photos/services/ml"; +import { + wipClusterEnable, + wipHasSwitchedOnceCmpAndSet, +} from "@/new/photos/services/ml"; import { EnteFile } from "@/new/photos/types/file"; import { mergeMetadata } from "@/new/photos/utils/file"; import { CenteredFlex } from "@ente/shared/components/Container"; @@ -674,9 +677,11 @@ export default function Gallery() { // TODO-Cluster if (process.env.NEXT_PUBLIC_ENTE_WIP_CL) { setTimeout(() => { - void wipClusterEnable().then( - (y) => y && router.push("cluster-debug"), - ); + if (!wipHasSwitchedOnceCmpAndSet()) { + void wipClusterEnable().then( + (y) => y && router.push("cluster-debug"), + ); + } }, 2000); } }, []); diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts index 6b0a72be69..9b8db7cb9c 100644 --- a/web/packages/new/photos/services/ml/index.ts +++ b/web/packages/new/photos/services/ml/index.ts @@ -337,6 +337,13 @@ export const wipClusterEnable = async (): Promise => // // TODO-Cluster temporary state here let _wip_isClustering = false; let _wip_searchPersons: SearchPerson[] | undefined; +let _wip_hasSwitchedOnce = false; + +export const wipHasSwitchedOnceCmpAndSet = () => { + if (_wip_hasSwitchedOnce) return true; + _wip_hasSwitchedOnce = true; + return false; +}; export const wipSearchPersons = async () => { if (!(await wipClusterEnable())) return []; @@ -370,10 +377,10 @@ export const wipClusterDebugPageContents = async (): Promise< _wip_searchPersons = undefined; triggerStatusUpdate(); - const { faceAndNeigbours, clusters } = await clusterFaces( + const { faceAndNeigbours, clusters, cgroups } = await clusterFaces( await faceIndexes(), ); - // const searchPersons = await convertToSearchPersons(clusters, cgroups); + const searchPersons = await convertToSearchPersons(clusters, cgroups); const localFiles = await getAllLocalFiles(); const localFileByID = new Map(localFiles.map((f) => [f.id, f])); @@ -398,10 +405,9 @@ export const wipClusterDebugPageContents = async (): Promise< ); _wip_isClustering = false; - // _wip_searchPersons = searchPersons; + _wip_searchPersons = searchPersons; triggerStatusUpdate(); - // return { faces, clusters, cgroups }; return { faceFNs, clusters, clusterIDForFaceID }; };