From 295f4a0c2a5745ad7a367e59666acd9d5839cf36 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 18 May 2024 07:27:58 +0530 Subject: [PATCH] Essence --- web/apps/photos/src/services/face/types.ts | 8 -------- .../machineLearning/machineLearningService.ts | 18 ++++-------------- .../services/machineLearning/mlWorkManager.ts | 5 +---- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/web/apps/photos/src/services/face/types.ts b/web/apps/photos/src/services/face/types.ts index 01186192ab..cbe13da941 100644 --- a/web/apps/photos/src/services/face/types.ts +++ b/web/apps/photos/src/services/face/types.ts @@ -3,14 +3,6 @@ import { Dimensions } from "services/face/geom"; import { EnteFile } from "types/file"; import { Box, Point } from "./geom"; -export interface MLSyncResult { - nOutOfSyncFiles: number; - nSyncedFiles: number; - nSyncedFaces: number; - nFaceClusters: number; - error?: Error; -} - export declare type FaceDescriptor = Float32Array; export declare type Cluster = Array; diff --git a/web/apps/photos/src/services/machineLearning/machineLearningService.ts b/web/apps/photos/src/services/machineLearning/machineLearningService.ts index 2f01aec516..3703f1dfde 100644 --- a/web/apps/photos/src/services/machineLearning/machineLearningService.ts +++ b/web/apps/photos/src/services/machineLearning/machineLearningService.ts @@ -16,7 +16,6 @@ import { MLLibraryData, MLSearchConfig, MLSyncFileContext, - MLSyncResult, MlFileData, } from "services/face/types"; import { getLocalFiles } from "services/fileService"; @@ -151,7 +150,7 @@ class MachineLearningService { private localSyncContext: Promise; private syncContext: Promise; - public async sync(token: string, userID: number): Promise { + public async sync(token: string, userID: number): Promise { if (!token) { throw Error("Token needed by ml service to sync file"); } @@ -180,18 +179,9 @@ class MachineLearningService { } */ - const mlSyncResult: MLSyncResult = { - nOutOfSyncFiles: syncContext.outOfSyncFiles.length, - nSyncedFiles: syncContext.nSyncedFiles, - nSyncedFaces: syncContext.nSyncedFaces, - nFaceClusters: - syncContext.mlLibraryData?.faceClusteringResults?.clusters - .length, - error: syncContext.error, - }; - // log.info('[MLService] sync results: ', mlSyncResult); - - return mlSyncResult; + const error = syncContext.error; + const nOutOfSyncFiles = syncContext.outOfSyncFiles.length; + return !error && nOutOfSyncFiles > 0; } public async regenerateFaceCrop(faceID: string) { diff --git a/web/apps/photos/src/services/machineLearning/mlWorkManager.ts b/web/apps/photos/src/services/machineLearning/mlWorkManager.ts index d1421ac6bd..4653733545 100644 --- a/web/apps/photos/src/services/machineLearning/mlWorkManager.ts +++ b/web/apps/photos/src/services/machineLearning/mlWorkManager.ts @@ -269,11 +269,8 @@ class MLWorkManager { const userID = getUserID(); const jobWorkerProxy = await this.getSyncJobWorker(); - const mlSyncResult = await jobWorkerProxy.sync(token, userID); - + return await jobWorkerProxy.sync(token, userID); // this.terminateSyncJobWorker(); - return !mlSyncResult.error && mlSyncResult.nOutOfSyncFiles > 0; - // TODO: redirect/refresh to gallery in case of session_expired, stop ml sync job } catch (e) { log.error("Failed to run MLSync Job", e);