From debe8ddabb9891feed0821ddc4361c64752e436c Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 17 Oct 2026 14:31:03 +0200 Subject: [PATCH] launch: a missing picture reader file is fetched again instead of starting an engine that cannot read pictures --- strata_cli/launch/runner.py | 8 +++++++- tests/terminal/test_launch.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.py index 9b4bd425..ca209db5 100644 --- a/strata_cli/launch/runner.py +++ b/strata_cli/launch/runner.py @@ -119,6 +119,9 @@ def files_present(cfg: dict) -> list[str]: args = [str(a) for a in cfg.get("args") or []] if flag in args and args.index(flag) + 1 < len(args) and not Path(args[args.index(flag) + 1]).exists(): missing.append(args[args.index(flag) + 1]) + vision = cfg.get("vision") + if isinstance(vision, dict) and vision.get("mmproj") and not Path(str(vision["mmproj"])).exists(): + missing.append(str(vision["mmproj"])) # the picture reader's file: setup fetches it again return missing @@ -374,7 +377,10 @@ class Runner: return 0.0 try: path, desc = self.installed_state() - if path is not None and desc is not None and not files_present(read_config(path)): + lost = files_present(read_config(path)) if path is not None else [] + if lost and all("mmproj" in Path(x).name.lower() for x in lost): + return 0.9 # only the picture reader's file is gone + if path is not None and desc is not None and not lost: if desc_matches(desc, s): return 0.0 # the model is on disk: what differs is the context / memory format (nothing to download) or the pictures (the 0.9 GB reader file) diff --git a/tests/terminal/test_launch.py b/tests/terminal/test_launch.py index f405e90a..bd4fb2a5 100644 --- a/tests/terminal/test_launch.py +++ b/tests/terminal/test_launch.py @@ -424,6 +424,22 @@ class AdoptRules(unittest.TestCase): with mock.patch.object(r, "installed_state", return_value=(cfgfile, desc)): self.assertAlmostEqual(r.download_gb(), want, msg=(vision, images, ctx)) + def test_a_missing_picture_reader_file_is_fetched_again(self): + from strata_cli.launch.runner import files_present + with Home() as h: + mm = h.base / "mmproj-x.gguf" + cfg = {"args": [], "vision": {"mmproj": str(mm)}} + self.assertEqual(files_present(cfg), [str(mm)]) + mm.write_text("x") + self.assertEqual(files_present(cfg), []) + mm.unlink() + cat = catalog(HW_12) + cfgfile = h.base / "strata-x.json" + cfgfile.write_text(json.dumps(cfg)) + r = Runner(S.LaunchSettings(family="qwen", model="IQ3_XXS", vision="on", context=32768), catalog=cat) + with mock.patch.object(r, "installed_state", return_value=(cfgfile, {"context": 32768, "kv": "int8", "images": "cpu"})): + self.assertAlmostEqual(r.download_gb(), 0.9) + def test_pictures_asked_but_still_off_is_said_in_plain_words(self): with Home() as h: cat = catalog(HW_12)