[mob] Fix redundant model download & rename (#2803)

## Description

## Tests
This commit is contained in:
Neeraj Gupta
2024-08-21 23:24:47 +05:30
committed by GitHub
12 changed files with 37 additions and 28 deletions

View File

@@ -108,6 +108,8 @@ PODS:
- GoogleUtilities/UserDefaults (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- heif_converter (1.0.0):
- Flutter
- home_widget (0.0.1):
- Flutter
- image_editor_common (1.0.0):
@@ -261,6 +263,7 @@ DEPENDENCIES:
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- flutter_sodium (from `.symlinks/plugins/flutter_sodium/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- heif_converter (from `.symlinks/plugins/heif_converter/ios`)
- home_widget (from `.symlinks/plugins/home_widget/ios`)
- image_editor_common (from `.symlinks/plugins/image_editor_common/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
@@ -361,6 +364,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_sodium/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
heif_converter:
:path: ".symlinks/plugins/heif_converter/ios"
home_widget:
:path: ".symlinks/plugins/home_widget/ios"
image_editor_common:
@@ -462,6 +467,7 @@ SPEC CHECKSUMS:
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
heif_converter: e3802659e4104e27e28c4d7bff07903da2f69318
home_widget: 0434835a4c9a75704264feff6be17ea40e0f0d57
image_editor_common: d6f6644ae4a6de80481e89fe6d0a8c49e30b4b43
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1

View File

@@ -305,6 +305,7 @@
"${BUILT_PRODUCTS_DIR}/flutter_secure_storage/flutter_secure_storage.framework",
"${BUILT_PRODUCTS_DIR}/flutter_sodium/flutter_sodium.framework",
"${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework",
"${BUILT_PRODUCTS_DIR}/heif_converter/heif_converter.framework",
"${BUILT_PRODUCTS_DIR}/home_widget/home_widget.framework",
"${BUILT_PRODUCTS_DIR}/image_editor_common/image_editor_common.framework",
"${BUILT_PRODUCTS_DIR}/image_picker_ios/image_picker_ios.framework",
@@ -400,6 +401,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_secure_storage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_sodium.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/heif_converter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/home_widget.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_editor_common.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker_ios.framework",

View File

@@ -62,7 +62,7 @@ class MLService {
/// Only call this function once at app startup, after that you can directly call [runAllML]
Future<void> init({bool firstTime = false}) async {
if (localSettings.isFaceIndexingEnabled == false || _isInitialized) {
if (localSettings.isMLIndexingEnabled == false || _isInitialized) {
return;
}
_logger.info("init called");
@@ -80,7 +80,7 @@ class MLService {
// Listen on MachineLearningController
Bus.instance.on<MachineLearningControlEvent>().listen((event) {
if (localSettings.isFaceIndexingEnabled == false) {
if (localSettings.isMLIndexingEnabled == false) {
return;
}
_mlControllerStatus = event.shouldRun;
@@ -572,7 +572,7 @@ class MLService {
void _logStatus() {
final String status = '''
isInternalUser: ${flagService.internalUser}
isFaceIndexingEnabled: ${localSettings.isFaceIndexingEnabled}
isMLIndexingEnabled: ${localSettings.isMLIndexingEnabled}
canRunMLController: $_mlControllerStatus
isIndexingOrClusteringRunning: $_isIndexingOrClusteringRunning
shouldPauseIndexingAndClustering: $_shouldPauseIndexingAndClustering

View File

@@ -42,7 +42,7 @@ class SemanticSearchService {
String? _latestPendingQuery;
Future<void> init() async {
if (!localSettings.isFaceIndexingEnabled) {
if (!localSettings.isMLIndexingEnabled) {
return;
}
if (_hasInitialized) {
@@ -60,7 +60,7 @@ class SemanticSearchService {
}
bool isMagicSearchEnabledAndReady() {
return localSettings.isFaceIndexingEnabled &&
return localSettings.isMLIndexingEnabled &&
_textModelIsLoaded &&
_cachedImageEmbeddings.isNotEmpty;
}
@@ -72,7 +72,7 @@ class SemanticSearchService {
if (!isMagicSearchEnabledAndReady()) {
if (flagService.internalUser) {
_logger.info(
"Magic search enabled ${localSettings.isFaceIndexingEnabled}, loaded $_textModelIsLoaded cached ${_cachedImageEmbeddings.isNotEmpty}",
"Magic search enabled ${localSettings.isMLIndexingEnabled}, loaded $_textModelIsLoaded cached ${_cachedImageEmbeddings.isNotEmpty}",
);
}
return (query, <EnteFile>[]);

View File

@@ -94,6 +94,9 @@ class MagicCacheService {
}
Future<void> _updateCacheIfTheTimeHasCome() async {
if (localSettings.isMLIndexingEnabled) {
return;
}
final jsonFile = await RemoteAssetsService.instance
.getAssetIfUpdated(_kMagicPromptsDataUrl);
if (jsonFile != null) {

View File

@@ -177,7 +177,7 @@ class SearchService {
}
Future<List<GenericSearchResult>> getMagicSectionResutls() async {
if (localSettings.isFaceIndexingEnabled && flagService.internalUser) {
if (localSettings.isMLIndexingEnabled && flagService.internalUser) {
return MagicCacheService.instance.getMagicGenericSearchResult();
} else {
return <GenericSearchResult>[];

View File

@@ -63,7 +63,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
builder: (context, snapshot) {
if (snapshot.hasData) {
return CaptionedTextWidget(
title: localSettings.isFaceIndexingEnabled
title: localSettings.isMLIndexingEnabled
? "Disable faces (${snapshot.data!} files done)"
: "Enable faces (${snapshot.data!} files done)",
);
@@ -76,7 +76,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
trailingIconIsMuted: true,
onTap: () async {
try {
final isEnabled = await localSettings.toggleFaceIndexing();
final isEnabled = await localSettings.toggleMLIndexing();
if (!isEnabled) {
MLService.instance.pauseIndexingAndClustering();
}

View File

@@ -66,7 +66,7 @@ class _MachineLearningSettingsPageState
@override
Widget build(BuildContext context) {
final hasEnabled = localSettings.isFaceIndexingEnabled;
final hasEnabled = localSettings.isMLIndexingEnabled;
return Scaffold(
body: CustomScrollView(
primary: false,
@@ -184,7 +184,7 @@ class _MachineLearningSettingsPageState
Future<void> toggleIndexingState() async {
final hasGivenConsent = UserRemoteFlagService.instance
.getCachedBoolValue(UserRemoteFlagService.mlEnabled);
if (!localSettings.isFaceIndexingEnabled && !hasGivenConsent) {
if (!localSettings.isMLIndexingEnabled && !hasGivenConsent) {
final result = await Navigator.push(
context,
MaterialPageRoute(
@@ -197,7 +197,7 @@ class _MachineLearningSettingsPageState
return;
}
}
final isEnabled = await localSettings.toggleFaceIndexing();
final isEnabled = await localSettings.toggleMLIndexing();
if (isEnabled) {
await MLService.instance.init(firstTime: true);
await SemanticSearchService.instance.init();
@@ -213,7 +213,7 @@ class _MachineLearningSettingsPageState
Widget _getMlSettings(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final hasEnabled = localSettings.isFaceIndexingEnabled;
final hasEnabled = localSettings.isMLIndexingEnabled;
return Column(
children: [
if (hasEnabled)
@@ -223,7 +223,7 @@ class _MachineLearningSettingsPageState
),
menuItemColor: colorScheme.fillFaint,
trailingWidget: ToggleSwitchWidget(
value: () => localSettings.isFaceIndexingEnabled,
value: () => localSettings.isMLIndexingEnabled,
onChanged: () async {
await toggleIndexingState();
},

View File

@@ -280,7 +280,7 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
]);
}
if (localSettings.isFaceIndexingEnabled) {
if (localSettings.isMLIndexingEnabled) {
fileDetailsTiles.addAll([
FacesItemWidget(file),
const FileDetailsDivider(),

View File

@@ -115,7 +115,7 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
itemBuilder: (context, index) {
switch (searchTypes[index]) {
case SectionType.face:
if (!localSettings.isFaceIndexingEnabled) {
if (!localSettings.isMLIndexingEnabled) {
return const SizedBox.shrink();
}
return PeopleSection(

View File

@@ -10,9 +10,7 @@ enum AlbumSortKey {
class LocalSettings {
static const kCollectionSortPref = "collection_sort_pref";
static const kPhotoGridSize = "photo_grid_size";
static const kEnableMagicSearch = "enable_magic_search";
static const kEnableFaceIndexing = "enable_face_indexing";
static const kEnableFaceClustering = "enable_face_clustering";
static const _kisMLIndexingEnabled = "ls.enable_ml_idx";
static const kRateUsShownCount = "rate_us_shown_count";
static const kEnableMultiplePart = "ls.enable_multiple_part";
static const kRateUsPromptThreshold = 2;
@@ -57,8 +55,11 @@ class LocalSettings {
return getRateUsShownCount() < kRateUsPromptThreshold;
}
bool get isFaceIndexingEnabled =>
_prefs.getBool(kEnableFaceIndexing) ?? false;
// remove `enable_face_indexing`fallback after sometime, affects internal users only
bool get isMLIndexingEnabled =>
_prefs.getBool(_kisMLIndexingEnabled) ??
_prefs.getBool('enable_face_indexing') ??
false;
bool get userEnabledMultiplePart =>
_prefs.getBool(kEnableMultiplePart) ?? false;
@@ -68,13 +69,10 @@ class LocalSettings {
return value;
}
bool get isFaceClusteringEnabled =>
_prefs.getBool(kEnableFaceIndexing) ?? false;
/// toggleFaceIndexing toggles the face indexing setting and returns the new value
Future<bool> toggleFaceIndexing() async {
await _prefs.setBool(kEnableFaceIndexing, !isFaceIndexingEnabled);
return isFaceIndexingEnabled;
Future<bool> toggleMLIndexing() async {
await _prefs.setBool(_kisMLIndexingEnabled, !isMLIndexingEnabled);
return isMLIndexingEnabled;
}
//#region todo:(NG) remove this section, only needed for internal testing to see

View File

@@ -12,7 +12,7 @@ description: ente photos application
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.9.24+924
version: 0.9.25+925
publish_to: none
environment: