[mob][photos] Logging

This commit is contained in:
laurenspriem 2024-05-21 16:56:00 +05:30
parent d235ff1035
commit 71d3427879
3 changed files with 47 additions and 28 deletions

View file

@ -143,10 +143,13 @@ class FaceMlService {
} }
canRunMLController = event.shouldRun; canRunMLController = event.shouldRun;
if (canRunMLController) { if (canRunMLController) {
_logger.info("MLController allowed running ML, faces indexing starting"); _logger.info(
"MLController allowed running ML, faces indexing starting",
);
unawaited(indexAndClusterAll()); unawaited(indexAndClusterAll());
} else { } else {
_logger.info("MLController stopped running ML, faces indexing paused"); _logger
.info("MLController stopped running ML, faces indexing paused");
pauseIndexing(); pauseIndexing();
} }
}); });
@ -1014,6 +1017,7 @@ class FaceMlService {
file = await getThumbnailForUploadedFile(enteFile); file = await getThumbnailForUploadedFile(enteFile);
} else { } else {
file = await getFile(enteFile, isOrigin: true); file = await getFile(enteFile, isOrigin: true);
// TODO: This is returning null for Pragadees for all files, so something is wrong here!
} }
if (file == null) { if (file == null) {
_logger.warning("Could not get file for $enteFile"); _logger.warning("Could not get file for $enteFile");

View file

@ -3,6 +3,7 @@ import "dart:math" show max, min;
import "package:flutter/material.dart"; import "package:flutter/material.dart";
import "package:intl/intl.dart"; import "package:intl/intl.dart";
import "package:logging/logging.dart";
import "package:photos/core/event_bus.dart"; import "package:photos/core/event_bus.dart";
import 'package:photos/events/embedding_updated_event.dart'; import 'package:photos/events/embedding_updated_event.dart';
import "package:photos/face/db.dart"; import "package:photos/face/db.dart";
@ -26,6 +27,8 @@ import "package:photos/ui/components/toggle_switch_widget.dart";
import "package:photos/utils/data_util.dart"; import "package:photos/utils/data_util.dart";
import "package:photos/utils/local_settings.dart"; import "package:photos/utils/local_settings.dart";
final _logger = Logger("MachineLearningSettingsPage");
class MachineLearningSettingsPage extends StatefulWidget { class MachineLearningSettingsPage extends StatefulWidget {
const MachineLearningSettingsPage({super.key}); const MachineLearningSettingsPage({super.key});
@ -65,6 +68,7 @@ class _MachineLearningSettingsPageState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final bool facesFlag = flagService.faceSearchEnabled; final bool facesFlag = flagService.faceSearchEnabled;
_logger.info("On page open, facesFlag: $facesFlag");
return Scaffold( return Scaffold(
body: CustomScrollView( body: CustomScrollView(
primary: false, primary: false,
@ -435,16 +439,22 @@ class FaceRecognitionStatusWidgetState
} }
Future<(int, int, int, double)> getIndexStatus() async { Future<(int, int, int, double)> getIndexStatus() async {
try {
final indexedFiles = await FaceMLDataDB.instance final indexedFiles = await FaceMLDataDB.instance
.getIndexedFileCount(minimumMlVersion: faceMlVersion); .getIndexedFileCount(minimumMlVersion: faceMlVersion);
final indexableFiles = (await FaceMlService.getIndexableFileIDs()).length; final indexableFiles = (await FaceMlService.getIndexableFileIDs()).length;
final showIndexedFiles = min(indexedFiles, indexableFiles); final showIndexedFiles = min(indexedFiles, indexableFiles);
final pendingFiles = max(indexableFiles - indexedFiles, 0); final pendingFiles = max(indexableFiles - indexedFiles, 0);
final foundFaces = await FaceMLDataDB.instance.getTotalFaceCount(); final foundFaces = await FaceMLDataDB.instance.getTotalFaceCount();
final clusteredFaces = await FaceMLDataDB.instance.getClusteredFaceCount(); final clusteredFaces =
await FaceMLDataDB.instance.getClusteredFaceCount();
final clusteringDoneRatio = clusteredFaces / foundFaces; final clusteringDoneRatio = clusteredFaces / foundFaces;
return (showIndexedFiles, pendingFiles, foundFaces, clusteringDoneRatio); return (showIndexedFiles, pendingFiles, foundFaces, clusteringDoneRatio);
} catch (e, s) {
_logger.severe('Error getting face recognition status', e, s);
rethrow;
}
} }
@override @override

View file

@ -37,6 +37,7 @@ Future<File?> getFile(
bool isOrigin = false, bool isOrigin = false,
} // only relevant for live photos } // only relevant for live photos
) async { ) async {
try {
if (file.isRemoteFile) { if (file.isRemoteFile) {
return getFileFromServer(file, liveVideo: liveVideo); return getFileFromServer(file, liveVideo: liveVideo);
} else { } else {
@ -57,6 +58,10 @@ Future<File?> getFile(
} }
return cachedFile; return cachedFile;
} }
} catch (e, s) {
_logger.warning("Failed to get file", e, s);
return null;
}
} }
Future<bool> doesLocalFileExist(EnteFile file) async { Future<bool> doesLocalFileExist(EnteFile file) async {