Inline
This commit is contained in:
parent
160e360941
commit
0f00803519
3 changed files with 41 additions and 22 deletions
|
@ -11,10 +11,7 @@ import PQueue from "p-queue";
|
|||
import downloadManager from "services/download";
|
||||
import { putEmbedding } from "services/embeddingService";
|
||||
import { getLocalFiles } from "services/fileService";
|
||||
import mlIDbStorage, {
|
||||
ML_SEARCH_CONFIG_NAME,
|
||||
ML_SYNC_CONFIG_NAME,
|
||||
} from "services/ml/db";
|
||||
import mlIDbStorage, { ML_SEARCH_CONFIG_NAME } from "services/ml/db";
|
||||
import {
|
||||
BlurDetectionMethod,
|
||||
BlurDetectionService,
|
||||
|
@ -52,7 +49,13 @@ import PeopleService from "./peopleService";
|
|||
import ReaderService from "./readerService";
|
||||
import yoloFaceDetectionService from "./yoloFaceDetectionService";
|
||||
|
||||
export const DEFAULT_ML_SYNC_CONFIG: MLSyncConfig = {
|
||||
/**
|
||||
* TODO-ML(MR): What and why.
|
||||
* Also, needs to be 1 (in sync with mobile) when we move out of beta.
|
||||
*/
|
||||
export const defaultMLVersion = 3;
|
||||
|
||||
const DEFAULT_ML_SYNC_CONFIG: MLSyncConfig = {
|
||||
batchSize: 200,
|
||||
imageSource: "Original",
|
||||
faceDetection: {
|
||||
|
@ -90,7 +93,7 @@ export const DEFAULT_ML_SYNC_CONFIG: MLSyncConfig = {
|
|||
// maxDistanceInsideCluster: 0.4,
|
||||
generateDebugInfo: true,
|
||||
},
|
||||
mlVersion: 3,
|
||||
mlVersion: defaultMLVersion,
|
||||
};
|
||||
|
||||
export const DEFAULT_ML_SEARCH_CONFIG: MLSearchConfig = {
|
||||
|
@ -99,10 +102,6 @@ export const DEFAULT_ML_SEARCH_CONFIG: MLSearchConfig = {
|
|||
|
||||
export const MAX_ML_SYNC_ERROR_COUNT = 1;
|
||||
|
||||
export async function getMLSyncConfig() {
|
||||
return mlIDbStorage.getConfig(ML_SYNC_CONFIG_NAME, DEFAULT_ML_SYNC_CONFIG);
|
||||
}
|
||||
|
||||
export async function getMLSearchConfig() {
|
||||
if (isInternalUserForML()) {
|
||||
return mlIDbStorage.getConfig(
|
||||
|
@ -481,9 +480,18 @@ class MachineLearningService {
|
|||
if (!this.syncContext) {
|
||||
log.info("Creating syncContext");
|
||||
|
||||
this.syncContext = getMLSyncConfig().then((mlSyncConfig) =>
|
||||
MLFactory.getMLSyncContext(token, userID, mlSyncConfig, true),
|
||||
);
|
||||
const mlSyncConfig = DEFAULT_ML_SYNC_CONFIG;
|
||||
// TODO-ML(MR): Keep as promise for now.
|
||||
this.syncContext = new Promise((resolve) => {
|
||||
resolve(
|
||||
MLFactory.getMLSyncContext(
|
||||
token,
|
||||
userID,
|
||||
mlSyncConfig,
|
||||
true,
|
||||
),
|
||||
);
|
||||
});
|
||||
} else {
|
||||
log.info("reusing existing syncContext");
|
||||
}
|
||||
|
@ -493,9 +501,18 @@ class MachineLearningService {
|
|||
private async getLocalSyncContext(token: string, userID: number) {
|
||||
if (!this.localSyncContext) {
|
||||
log.info("Creating localSyncContext");
|
||||
this.localSyncContext = getMLSyncConfig().then((mlSyncConfig) =>
|
||||
MLFactory.getMLSyncContext(token, userID, mlSyncConfig, false),
|
||||
);
|
||||
// TODO-ML(MR):
|
||||
this.localSyncContext = new Promise((resolve) => {
|
||||
const mlSyncConfig = DEFAULT_ML_SYNC_CONFIG;
|
||||
resolve(
|
||||
MLFactory.getMLSyncContext(
|
||||
token,
|
||||
userID,
|
||||
mlSyncConfig,
|
||||
false,
|
||||
),
|
||||
);
|
||||
});
|
||||
} else {
|
||||
log.info("reusing existing localSyncContext");
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import {
|
|||
import isElectron from "is-electron";
|
||||
import {
|
||||
DEFAULT_ML_SEARCH_CONFIG,
|
||||
DEFAULT_ML_SYNC_CONFIG,
|
||||
MAX_ML_SYNC_ERROR_COUNT,
|
||||
} from "services/machineLearning/machineLearningService";
|
||||
import { Face, MLLibraryData, MlFileData, Person } from "services/ml/types";
|
||||
|
@ -26,7 +25,6 @@ export interface IndexStatus {
|
|||
|
||||
interface Config {}
|
||||
|
||||
export const ML_SYNC_CONFIG_NAME = "ml-sync";
|
||||
export const ML_SEARCH_CONFIG_NAME = "ml-search";
|
||||
|
||||
const MLDATA_DB_NAME = "mldata";
|
||||
|
@ -141,10 +139,11 @@ class MLIDbStorage {
|
|||
DEFAULT_ML_SYNC_JOB_CONFIG,
|
||||
"ml-sync-job",
|
||||
);
|
||||
*/
|
||||
|
||||
await tx
|
||||
.objectStore("configs")
|
||||
.add(DEFAULT_ML_SYNC_CONFIG, ML_SYNC_CONFIG_NAME);
|
||||
*/
|
||||
}
|
||||
if (oldVersion < 3) {
|
||||
await tx
|
||||
|
@ -163,6 +162,10 @@ class MLIDbStorage {
|
|||
.objectStore("configs")
|
||||
.delete(ML_SEARCH_CONFIG_NAME);
|
||||
|
||||
await tx
|
||||
.objectStore("configs")
|
||||
.delete(""ml-sync"");
|
||||
|
||||
await tx
|
||||
.objectStore("configs")
|
||||
.delete("ml-sync-job");
|
||||
|
|
|
@ -2,7 +2,7 @@ import { FILE_TYPE } from "@/media/file-type";
|
|||
import log from "@/next/log";
|
||||
import * as chrono from "chrono-node";
|
||||
import { t } from "i18next";
|
||||
import { getMLSyncConfig } from "services/machineLearning/machineLearningService";
|
||||
import { defaultMLVersion } from "services/machineLearning/machineLearningService";
|
||||
import mlIDbStorage from "services/ml/db";
|
||||
import { Person } from "services/ml/types";
|
||||
import { Collection } from "types/collection";
|
||||
|
@ -175,8 +175,7 @@ export async function getAllPeopleSuggestion(): Promise<Array<Suggestion>> {
|
|||
|
||||
export async function getIndexStatusSuggestion(): Promise<Suggestion> {
|
||||
try {
|
||||
const config = await getMLSyncConfig();
|
||||
const indexStatus = await mlIDbStorage.getIndexStatus(config.mlVersion);
|
||||
const indexStatus = await mlIDbStorage.getIndexStatus(defaultMLVersion);
|
||||
|
||||
let label;
|
||||
if (!indexStatus.localFilesSynced) {
|
||||
|
|
Loading…
Add table
Reference in a new issue