launch: a missing picture reader file is fetched again instead of starting an engine that cannot read pictures
This commit is contained in:
1 parent
e29112390f
commit
debe8ddabb
2 files changed
+23
-1
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user