fix(ml): preloaded model loaded twice (#32610)

fix(ml): reuse cached model across names that clean to the same model

(cherry picked from commit 166e93559f123313cf9cb4e7324c4ee30e21c618)
This commit is contained in:
Yaros
2026-10-22 05:23:22 +03:00
committed by Codex
parent 01ba579766
commit 3f3671fbe5
2 changed files with 11 additions and 1 deletions
+8
View File
@@ -1856,6 +1856,14 @@ class TestCache:
assert len(model_cache._models) == 1
model.create.assert_called_once()
async def test_shares_an_instance_across_names_of_the_same_model(self) -> None:
model_cache = ModelCache()
bare = model_cache.get(InferenceEntry(OpenClipTextualEncoder, "ViT-B-32__openai", TextualOptions()))
prefixed = model_cache.get(
InferenceEntry(OpenClipTextualEncoder, "immich-app/ViT-B-32__openai", TextualOptions(language="en-US"))
)
assert bare is prefixed
async def test_separate_instances_per_graph_option(self) -> None:
# the real TextDetector, so that keying it on anything but its resolution fails this
model_cache = ModelCache()