-
Notifications
You must be signed in to change notification settings - Fork 68
Feat: Remove preloading for all assets except memories #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This will only work if Immich supports it, if not it will fallback to the old method Also refactors code to disambiguate preloading versus not pools
- Standardized ImmichApi mock instantiation across test suites using constructor with dummy arguments (`new Mock<ImmichApi>("http://dummy-url.com", new HttpClient())`) to resolve proxy creation issues.
- Corrected IApiCache mock instantiation to `new Mock<IApiCache>()`.
- Refined Moq `Verify` calls to use property-based matching (`It.Is<T>(predicate)`) instead of specific object instances for DTOs, fixing verification failures in `AllAssetsRemotePoolTests`.
- Made `BaseCircuitBreaker.DoCall` async-aware to correctly handle exceptions from asynchronous primary operations, allowing the circuit breaker fallback to be properly tested and trigger. Updated consuming classes accordingly.
- Adjusted cache count assertion in `AllAssetsRemotePoolTests.GetAssetCount_CallsApiAndFallsBack` to reflect expected interactions after the circuit breaker fix.
- Updated Moq setup/verify in `PersonAssetsPreloadPoolTests.LoadAssets_CallsSearchAssetsForEachPerson_AndPaginates` to use a detailed predicate helper for `MetadataSearchDto`.
These changes resolve a large number of test failures. One test (`LoadAssets_CallsSearchAssetsForEachPerson_AndPaginates`) remains failing due to a Moq verification mismatch that requires further investigation.
- Corrected Moq predicate in `PersonAssetsPreloadPoolTests` with a detailed helper method `VerifyMetadataSearchDto` including explicit HasValue checks for nullable properties. (Note: This test still fails, Moq verification issue persists). - Adjusted assertion in `AllAssetsRemotePoolTests.GetAssetCount_CallsApiAndFallsBack` for `_fakeCache.Count` to be 2, as the circuit breaker fix correctly logs fallback and the cache interacts twice. This resolves all but one test failure. The remaining failure in `PersonAssetsPreloadPoolTests.LoadAssets_CallsSearchAssetsForEachPerson_AndPaginates` is a persistent Moq verification issue.
|
I am opening this PR to discuss the path to removing asset caching. I have done a little work on this and the current state is this:
I also just realised that our So this would mean there would be a main pool of photos, plus possibly a favorites pool if we keep the existing behaviour. We also support ExcludedAlbums, which Immich doesn't. They do want to though. As this is an exclusion, rather than an inclusion like all the other filters, it's a bit awkward to implement when not caching. Pulling photos is fine (we can skip the ones that are excluded), but counting the total is problematic. The simplest option is to just ignore the excluded counts (this just means that there will marginally more chance of photos from the main pool being selected), a slightly more accurate option may be to subtract the count of all (potentially) excluded assets, which will probably be a bit more accurate but swing the probabilities the other way (note that if we don't have a favorites pool, and the user is not using memories, the probability doesn't matter as there's only a single pool). The last thing is memories, which needs to be a distinct pool (as Immich don't want these combined into photo search results). I will add a resource to Immich to pull random memories (which I haven't yet done). One thing that I will point out is that there will probably be quite a bit of extra code when supporting older versions of Immich too - lots of additional pool types, caching options + circuit breakers that fall back from remote calls to caching ones. If you don't think we should go down this path (and just require the latest version), then please let me know and I'll simplify things! |
|
I don't think it is unreasonable to require a minimum version of Immich server, this is pretty common practice and would simplify things greatly for us. Just put it in the release notes as the first item. |
|
Well actually I've been a bit confused about how all the options interacted, however, looking at the source that I copied I don't think that I changed anything: ImmichFrame/ImmichFrame.Core/Logic/OptimizedImmichFrameLogic.cs Lines 84 to 95 in b19c00c
This is the source from before my changes, and you can see that assets are concatenated together, both favorites & memories. I believe that the only option that you can provide that removes images is |
|
Sorry, i wasn't very clear. If you ONLY set ShowMemories (no albums, people, or favorites) it would only show you memories. I just did that but it is just showing me random images now. |
|
Hmm, I certainly didn't intend to change that, the code is pretty similar: ImmichFrame/ImmichFrame.Core/Logic/PooledImmichFrameLogic.cs Lines 30 to 49 in 8fdbff2
|
|
Can you try? Maybe it’s just me? |
|
Immich PR to add random memory fetching: immich-app/immich#20025 |
Are the random images actually images in memories? Looking at the code it is pulling memories, then aggregating all the assets that form that memory. They were also then being shuffled (fixed in #436), so could just look like random images? |
I'm an idiot, sorry. It is working fine. I had settings as ENV in compose, but also had Json settings i forgot about. It of course prefers Json so i wasn't changing anything. ugh..... |
|
Update: the recent Immich release included my last change, which was to allow fetching a (limited & random) set of memories. This was the last change to Immich to allow us to purely fetch on-demand, without having to sort or filter ourselves. The only remaining thing to decide ahead of doing this would be how we handle the cases where we've diverged from how Immich perform searching/filtering:
Both of these can be worked around, the decision is whether we want to stay close to what Immich provides versus diverge from it (which gives more flexibility for users, but creates more work here). |
I'd personally would love to ditch the whole logic and let immich do the heavy lifting, but honestly, I don't think this is really an option as you said it would limit the flexibility for users. Do you have something specific in mind? |
Work in progress; not yet ready for merging...