Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
--model-path and --data-dir win over an installed copy with the same model and context (C08)
Niko1221092a62daaa21
diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.pyindex b7a9469aa..4641a332d 100644--- a/strata_cli/launch/runner.py+++ b/strata_cli/launch/runner.py@@ -231,6 +231,11 @@ def desc_matches(desc: dict, s: S.LaunchSettings) -> bool:return True+def _inside(path: Path, folder: Path) -> bool:+ a, b = os.path.normcase(str(path)), os.path.normcase(str(folder))+ return a == b or a.startswith(b.rstrip("\\/") + os.sep)++def files_present(cfg: dict) -> list[str]:"""The model files a run config names that are missing (empty list: all there)."""missing = []@@ -776,6 +781,32 @@ class Runner:desc = self.catalog.strata.describe_config(path)return path, desc+ def installed_serves_request(self, path: Path) -> bool:+ """C08: the installed copy is what this launch asked for. A --model-path (or the Folder step's own files) and a --data-dir always win:+ when the installed config names files outside them, it is not reused (that served another copy without a word) and setup runs with+ the given folders, which rewrites the config so the profile follows."""+ s = self.s+ if not (s.model_path or s.data_dir):+ return True+ try:+ cfg = read_config(path)+ args = [str(a) for a in cfg.get("args") or []]+ if s.model_path:+ want = Path(s.model_path).expanduser().resolve()+ folder = want if want.is_dir() else want.parent+ ggufs = [Path(a) for a in args if a.lower().endswith(".gguf")]+ if not ggufs or not all(_inside(g.resolve(), folder) for g in ggufs):+ return False+ if s.data_dir:+ packs = [Path(args[i + 1]) for i, a in enumerate(args[:-1]) if a == "--pack"]+ return all(_inside(pk.resolve(), Path(s.data_dir).expanduser().resolve()) for pk in packs)+ return True+ from strata_control import discovery+ found = discovery.footprint(cfg, path).data_dir+ return found is not None and os.path.normcase(str(Path(found).resolve())) == os.path.normcase(str(Path(s.data_dir).expanduser().resolve()))+ except Exception: # noqa: BLE001 - when in doubt do what was asked: run setup with the given folders+ return False+def existing_data_dir(self) -> Path | None:"""The data folder to give setup when the person chose none: the folder the model already lives in (its run config names its files),else the folder the desktop app uses, so a helper file that is missing is fetched next to the rest, never into a second folder.@@ -879,8 +910,11 @@ class Runner:raise LaunchError("No model was chosen.", "Choose a model, or use --model NAME (strata launch --help lists them).", 2)path, desc = self.installed_state()if path is not None and desc is not None and desc_matches(desc, s) and not files_present(read_config(path)):- self.emit("model", f"{s.family} {s.model} is already installed with these choices.", 100)- return path+ if self.installed_serves_request(path):+ self.emit("model", f"{s.family} {s.model} is already installed with these choices.", 100)+ return path+ self.emit("model", "The model already installed here is somewhere else than the folder you gave, so Strata uses the folder you gave "+ "and points this launch at it.", 0)title = f"{s.family} {s.model}"if sys.platform == "darwin" and not (cat.src / "strata_control" / "mac_fit.py").is_file():# a Terminal from before the Mac rules moved into strata_control/mac_fit.py: setup.py cannot install a Mac model in its Controldiff --git a/tests/terminal/test_tui_stress_launch.py b/tests/terminal/test_tui_stress_launch.pyindex 7514ae7f2..f64addc0a 100644--- a/tests/terminal/test_tui_stress_launch.py+++ b/tests/terminal/test_tui_stress_launch.py@@ -148,5 +148,72 @@ class SecondLaunchTests(unittest.TestCase):self.assertIn("--restart", f.read())+class ModelPathWins(unittest.TestCase):+ """C08: --model-path and --data-dir are honoured even when an installed copy with the same model and context exists."""++ def setUp(self):+ import json+ import tempfile+ from pathlib import Path+ self.home = Home().__enter__()+ self.addCleanup(self.home.__exit__, None, None, None)+ p = mock.patch.object(Catalog, "hardware", lambda self, fresh=False: dict(HW_12, disk_free_gb=500.0))+ p.start()+ self.addCleanup(p.stop)+ self.tmp = tempfile.TemporaryDirectory()+ self.addCleanup(self.tmp.cleanup)+ self.base = Path(self.tmp.name)+ self.installed = self.base / "dl-data"+ (self.installed / "models" / "Q2_0").mkdir(parents=True)+ self.gguf = self.installed / "models" / "Q2_0" / "m.gguf"+ self.gguf.write_bytes(b"x")+ self.pack = self.installed / "packs" / "q2_0"+ self.pack.mkdir(parents=True)+ self.cfg_path = self.base / "strata-q2_0.json"+ self.cfg_path.write_text(json.dumps({"args": ["--model", str(self.gguf), "--pack", str(self.pack), "--max-context", "32768"]}), encoding="utf-8")+ self.mine = self.base / "documents"+ self.mine.mkdir()+ (self.mine / "mine.gguf").write_bytes(b"y")++ def runner(self, **fields):+ s = S.LaunchSettings(family="qwen", model="Q2_0", context=32768, **fields)+ return Runner(s, catalog=catalog())++ def test_installed_copy_serves_when_nothing_was_given(self):+ self.assertTrue(self.runner().installed_serves_request(self.cfg_path))++ def test_a_model_path_elsewhere_is_not_served_by_the_installed_copy(self):+ self.assertFalse(self.runner(model_path=str(self.mine)).installed_serves_request(self.cfg_path))+ self.assertFalse(self.runner(model_path=str(self.mine / "mine.gguf")).installed_serves_request(self.cfg_path))++ def test_a_model_path_that_is_the_installed_folder_is_the_installed_copy(self):+ self.assertTrue(self.runner(model_path=str(self.installed / "models" / "Q2_0")).installed_serves_request(self.cfg_path))++ def test_a_data_dir_elsewhere_is_not_served_by_the_installed_copy(self):+ self.assertFalse(self.runner(data_dir=str(self.base / "c08-data")).installed_serves_request(self.cfg_path))+ self.assertTrue(self.runner(data_dir=str(self.installed)).installed_serves_request(self.cfg_path))++ def test_ensure_model_runs_setup_with_the_given_path_instead_of_reusing_the_profile(self):+ r = self.runner(model_path=str(self.mine))+ said = []+ r.emit_cb = lambda e: said.append(e.text)+ desc = {"context": 32768, "kv": "int8", "images": "off"}+ with mock.patch.object(Runner, "check_own_files"), mock.patch.object(Runner, "resolved_vision"), mock.patch.object(Runner, "installed_state", return_value=(self.cfg_path, desc)), mock.patch.object(Runner, "_spawn", side_effect=RuntimeError("setup would run")):+ with self.assertRaises(RuntimeError):+ r.ensure_model()+ self.assertFalse(any("already installed with these choices" in x for x in said))+ self.assertTrue(any("uses the folder you gave" in x for x in said))+ self.assertIn(str(self.mine), r.setup_args())++ def test_without_a_path_the_installed_copy_is_still_reused(self):+ r = self.runner()+ said = []+ r.emit_cb = lambda e: said.append(e.text)+ desc = {"context": 32768, "kv": "int8", "images": "off"}+ with mock.patch.object(Runner, "check_own_files"), mock.patch.object(Runner, "resolved_vision"), mock.patch.object(Runner, "installed_state", return_value=(self.cfg_path, desc)):+ self.assertEqual(r.ensure_model(), self.cfg_path)+ self.assertTrue(any("already installed with these choices" in x for x in said))++if __name__ == "__main__":unittest.main()