diff --git a/apps/desktop/scripts/vision-e2e.mjs b/apps/desktop/scripts/vision-e2e.mjs new file mode 100644 index 00000000..809050a4 --- /dev/null +++ b/apps/desktop/scripts/vision-e2e.mjs @@ -0,0 +1,121 @@ +#!/usr/bin/env node +/** + * Picture reading in the APP, end to end on a test box, through the installed app layout (packaged host + bundled Control + a real engine component + * that carries strata-vision): + * Download and prepare with "Read pictures" ON (the picture-reader file is fetched, the vision settings are written), load the model with the picture + * reader, send a real picture through the host's own /v1 endpoint and check that the answer names what is in it, unload, shut down. + * + * node vision-e2e.mjs --install --components > \ + * --work --family qwen --model IQ3_XXS --data --image shapes.png [--device cpu|gpu] + * + * The picture has a red circle, a blue square, a green triangle and the text "STRATA 42". The run exits 1 if any step fails. + */ +import { spawn } from 'node:child_process'; +import { existsSync, mkdirSync, readFileSync, readdirSync, statSync } from 'node:fs'; +import { createServer } from 'node:net'; +import { join, resolve } from 'node:path'; + +const args = Object.fromEntries(process.argv.slice(2).reduce((acc, a, i, all) => (a.startsWith('--') ? [...acc, [a.slice(2), all[i + 1]?.startsWith('--') || all[i + 1] === undefined ? true : all[i + 1]]] : acc), [])); +for (const need of ['install', 'components', 'work', 'model', 'image']) if (!args[need]) { console.error('missing --' + need); process.exit(2); } +const install = resolve(args.install), work = resolve(args.work), components = resolve(args.components), family = String(args.family ?? 'qwen'), modelId = String(args.model); +const device = String(args.device ?? 'cpu'); +const node = join(install, 'node', 'node'), hostEntry = join(install, 'host', 'server', 'index.mjs'), controlDir = join(install, 'control'); +const dirs = { models: join(work, 'models'), profiles: join(work, 'profiles'), runtime: join(work, 'runtime'), home: join(work, 'home'), xdg: join(work, 'xdg'), appdata: join(work, 'appdata') }; +for (const d of [dirs.models, dirs.home, dirs.xdg, dirs.appdata]) mkdirSync(d, { recursive: true }); +const delay = ms => new Promise(r => setTimeout(r, ms)); +let failed = false; +const record = (name, ok, detail = '') => { if (!ok) failed = true; console.log(`${ok ? 'ok ' : 'FAIL'} ${name}${detail ? ' ' + String(detail).slice(0, 600) : ''}`); }; +const freePort = async () => { const s = createServer(); await new Promise(r => s.listen(0, '127.0.0.1', r)); const p = s.address().port; await new Promise(r => s.close(r)); return p; }; +const env = { ...process.env, STRATA_COMPONENTS_DIR: components, STRATA_PROFILE_DIR: dirs.profiles, STRATA_RUNTIME_DIR: dirs.runtime, STRATA_INSTALL_DIR: dirs.models, + STRATA_HOME: dirs.home, STRATA_MODELS_DIR: join(work, 'models-unused'), APPDATA: dirs.appdata, XDG_CONFIG_HOME: dirs.xdg, PYTHONDONTWRITEBYTECODE: '1' }; +delete env.STRATA_API_KEY; +const port = await freePort(); +const base = `http://127.0.0.1:${port}`; +const host = spawn(node, [hostEntry], { cwd: join(install, 'host'), stdio: ['ignore', 'pipe', 'pipe'], + env: { ...env, STRATA_PORT: String(port), STRATA_DIST: join(install, 'host', 'dist'), NODE_ENV: 'production', STRATA_PACKAGED: '1', STRATA_REAL_ENGINE: '1', STRATA_NO_ACQUIRE: '1', + STRATA_SHARE_PORT: String(await freePort()), STRATA_TUNNEL_PORT: String(await freePort()) } }); +let hostLog = ''; +host.stdout.on('data', c => { hostLog += c; }); host.stderr.on('data', c => { hostLog += c; }); +const call = async (path, method = 'GET', body) => { + const response = await fetch(base + path, { method, headers: { 'content-type': 'application/json' }, body: body === undefined ? undefined : JSON.stringify(body) }); + return { status: response.status, body: await response.json().catch(() => null) }; +}; +async function waitJob(id, seconds) { + let last = ''; + for (let i = 0; i < seconds * 2; i++) { + const state = (await call('/api/native')).body; + const job = state.jobs.find(j => j.id === id); + if (job && job.summary !== last) { last = job.summary; console.log(' ... ' + String(last).slice(0, 120)); } + if (job && job.state !== 'running') return { job, state }; + await delay(500); + } + throw new Error('operation did not finish'); +} +async function main() { + let up = false; + for (let i = 0; i < 200 && !up; i++) { try { up = (await fetch(base + '/api/health')).ok; } catch { /* not yet */ } if (!up) await delay(150); } + record('host healthy', up, up ? base : hostLog.slice(-500)); + if (!up) return; + const packages = existsSync(join(components, 'engine')) ? readdirSync(join(components, 'engine')) : []; + const reader = packages.some(p => existsSync(join(components, 'engine', p, 'strata-vision'))); + record('the engine component carries the picture reader (strata-vision)', reader, packages.join(', ')); + const status = (await call('/api/control/status')).body; + record('Control: engine usable', status.engine?.usable === true, `engine=${status.engine?.engine?.version}`); + + // ---- Download and prepare, "Read pictures" on (the app sends vision "yes" for the download) + const values = { family, model: modelId, context: 32768, vision: 'yes', loadVision: device, ...(args.data ? { data_dir: resolve(args.data) } : {}) }; + const plan = await call('/api/native/plan', 'POST', values); + record('the plan for the download is made', plan.status === 200, JSON.stringify(plan.body).slice(0, 300)); + const started = await call('/api/native/operations', 'POST', { kind: 'install', args: values }); + record('the install operation starts', started.status === 200 || started.status === 202, JSON.stringify(started.body).slice(0, 200)); + const done = await waitJob(started.body.id, 3600); + record('Download and prepare finishes', done.job.state === 'done', `${done.job.state} ${done.job.error ?? done.job.summary}`); + const native = (await call('/api/native?refresh=1')).body; + console.log(' installed models: ' + JSON.stringify((native.installed?.models ?? []).map(m => ({ id: m.id, model: m.model, ready: m.ready, visionPrepared: m.visionPrepared, images: m.images, config: m.config })))); + const want = modelId.toLowerCase(); + const model = native.installed?.models?.find(m => [m.id, m.model, m.tag].some(x => String(x ?? '').toLowerCase() === want)); + record('the model is installed with the picture reader prepared (visionPrepared)', !!model?.visionPrepared, JSON.stringify({ ready: model?.ready, visionPrepared: model?.visionPrepared, images: model?.images })); + const configFile = model?.configPath ?? (model?.config ? join(dirs.models, model.config) : null); + let cfg = {}; + try { cfg = JSON.parse(readFileSync(configFile, 'utf8')); } catch { /* reported below */ } + const mm = cfg.vision?.mmproj; + record('the run settings carry the vision entry and --vision, and the mmproj file is on disk', + !!cfg.vision && (cfg.args ?? []).includes('--vision') && !!mm && existsSync(mm) && statSync(mm).size > 800e6, + `vision=${cfg.vision ? 'yes' : 'no'} --vision=${(cfg.args ?? []).includes('--vision')} mmproj=${mm ? Math.round(statSync(mm).size / 1048576) + ' MB' : 'none'}`); + + // ---- load with the picture reader + const load = await call('/api/native/operations', 'POST', { kind: 'load', args: { model: model?.model ?? modelId.toLowerCase(), vision: device } }); + const loaded = await waitJob(load.body.id, 900); + const instance = loaded.state.instances[0]; + record('load starts the engine with the picture reader', loaded.job.state === 'done' && instance?.status === 'ready', `${loaded.job.state} ${loaded.job.error ?? ''}; instance=${instance?.status}; vision=${instance?.vision}`); + record('the host says the loaded model reads pictures', !!instance?.vision, `vision=${instance?.vision}`); + + // ---- a real picture through the host's own /v1 endpoint + const png = readFileSync(resolve(args.image)).toString('base64'); + const t = Date.now(); + let answer = '', finish = ''; + for (const budget of [1536, 4096]) { + const chat = await call('/v1/chat/completions', 'POST', { model: instance?.apiModelId ?? modelId, max_tokens: budget, stream: false, messages: [{ role: 'user', content: [ + { type: 'text', text: 'Describe this picture: name each shape with its colour and read out any text.' }, + { type: 'image_url', image_url: { url: 'data:image/png;base64,' + png } }] }] }); + const choice = chat.body?.choices?.[0] ?? {}; + answer = choice.message?.content ?? ''; + finish = choice.finish_reason ?? String(chat.status); + if (answer.trim() || finish !== 'length') break; + } + console.log(` answer (${Math.round((Date.now() - t) / 1000)} s, finish=${finish}): ${JSON.stringify(answer.slice(0, 300))}`); + const low = answer.toLowerCase(); + record('the answer names the red circle', /red|circle/.test(low)); + record('the answer names the blue square', /blue|square/.test(low)); + record('the answer names the green triangle', /green|triangle/.test(low)); + record('the answer reads STRATA 42', low.includes('42')); + + // ---- unload + const unloaded = await call(`/api/native/instances/${instance?.id}/unload`, 'POST', {}); + record('unload', unloaded.status === 200, unloaded.status); +} +try { await main(); } catch (e) { record('run', false, e.stack ?? e); } +host.kill(); +await delay(1500); +console.log(failed ? 'VISION-E2E FAIL' : 'VISION-E2E PASS'); +process.exit(failed ? 1 : 0); diff --git a/docs/TERMINAL_LAUNCH.md b/docs/TERMINAL_LAUNCH.md index 9c048a1b..fe62b120 100644 --- a/docs/TERMINAL_LAUNCH.md +++ b/docs/TERMINAL_LAUNCH.md @@ -25,7 +25,10 @@ to your graphics card) comes with the first model: `strata launch` fetches the o *(Cards: only with two or more usable graphics cards.)* 3. **Folder**: where model files are stored, free space shown. 4. **Context** (8K to 512K, with the extra memory each costs) and the memory format (`m`: 8-bit or 4-bit). -5. **Pictures**: only for models that can read them; says what it adds. +5. **Pictures**: only for models that can read them; says what it adds (about 0.9 GB: the picture-reader file, downloaded with the model through + setup's Control mode, the same path the app's "Read pictures" uses). On a card under 24 GB and on AMD the picture reader runs on the CPU (nothing taken + from the graphics card); on a bigger NVIDIA card it runs on the GPU. It needs `strata-vision` beside the engine in the engine package; the screen + warns in plain words when the installed engine has none, and the run says "Pictures could not be switched on" instead of silently answering text only. 6. **Parallel requests**: "fit to your card" (12 GB: 1, 20: 2, 24: 3, 32+: 4) or 1 to 4; a warning if it will not fit. 7. **Tuning**: quick (about 20 minutes) / thorough (up to 2 hours) / skip (`strata tune auto`; the "answers may change very slightly" tick is off). 8. **Advanced** (optional): every engine setting with default, tuned value and your value; edit, reset, add a setting by name (checked against the engine's own list; a warning, not a refusal); diff --git a/packaging/package_engine.py b/packaging/package_engine.py index 6dd5b125..1b6c33c7 100644 --- a/packaging/package_engine.py +++ b/packaging/package_engine.py @@ -14,7 +14,8 @@ checks and starts; it is not signed, not published, and nothing here uploads it. (`engine_component.register_signature_verifier`); `--sign-with` is deliberately absent until then. Files taken from --src, by default: the entrypoint, every `*.dll` / `*.so` / `*.so.*` / `*.dylib` / `*.metallib` -beside it, `BUILD.json`, and `LICENSE*`. `--include GLOB` (repeatable, relative to --src, `**` allowed) adds more, for +beside it, `BUILD.json`, `LICENSE*`, and the picture reader `strata-vision[.exe]` when the build has one (without it the +engine answers text only: setup.py Control mode keeps the person's picture choice only when it is there). `--include GLOB` (repeatable, relative to --src, `**` allowed) adds more, for example `strata-vision.exe`, `strata-device.exe` or `rocm/**`. `--tree` takes every regular file under --src (the HIP package ships a `rocm/` tree of kernels). Symlinks are never followed or copied. """ @@ -49,7 +50,7 @@ def sha256(path: Path) -> str: def wanted(path: Path) -> bool: name = path.name.lower() return (name.endswith((".dll", ".so", ".dylib", ".metallib")) or ".so." in name or name == "build.json" - or name.startswith("license")) + or name.startswith("license") or name in ("strata-vision", "strata-vision.exe")) # the picture reader beside the engine (pictures need it) def git_build_id(repo: Path = ROOT) -> str: diff --git a/setup.py b/setup.py index ca273381..60663fc3 100644 --- a/setup.py +++ b/setup.py @@ -5837,7 +5837,10 @@ def control_engine_step(gpu, vision): warn(f"no engine is installed for this PC yet ({e}). The model is downloaded and prepared now; install the engine " "component for your GPU (a later step of the app, or the Terminal) before loading it") if vision != "none": - warn("images are not part of the app's first release: images off for this model") + if (eng / VEXE).is_file(): + ok(f"image encoder: {eng / VEXE} (carried by the engine component)") + return llama, eng, meta, [], gpu, vision + warn("this engine component has no image encoder (strata-vision): images off for this model") return llama, eng, meta, [], gpu, "none" @@ -6273,7 +6276,7 @@ def mac_control_setup(a) -> int: for n in MF.model_note(model, ram): warn(n) if a.vision in ("yes", "gpu", "cpu"): - warn("images are not part of the app's first release: images off for this model") + warn("the Mac engine has no picture reader yet: images off for this model (text works as usual)") ctx = a.context or MF.recommend_context(ram) if ctx > MF.TESTED_CONTEXT: say(f" context {ctx}: measured on the Mac up to {MF.TESTED_CONTEXT} (needles found at 8K-32K); longer is kept") diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.py index 88a8ff00..3d249bcb 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 @@ -301,6 +304,29 @@ class Runner: self.emit("engine", "The engine is installed.", 100) # ---- 2. the model + def vision_word(self) -> str: + """What setup is told for the picture choice. "on" is setup's "yes": setup (Control mode) picks the CPU encoder on a card under 24 GB + and on AMD, the GPU encoder on a bigger NVIDIA card, and downloads the pinned picture-reader file (mmproj) with the model.""" + s = self.s + if s.vision == "off": + return "no" + return "yes" if s.vision == "on" else s.vision + + def check_pictures(self, path: Path) -> None: + """Pictures were asked for: say so in plain words when the installed settings still have them off.""" + s = self.s + if s.vision == "off": + return + try: + desc = self.catalog.strata.describe_config(path) + except Exception: # noqa: BLE001 + return + if (desc or {}).get("images") in (None, "off"): + note = ("Pictures could not be switched on: this engine does not carry the picture reader, or this model cannot read pictures, " + "so it will answer text only.") + self.notices.append(note) + self.emit("model", note, 100, level="warn") + def setup_args(self) -> list[str]: cat, s = self.catalog, self.s fam, model = s.family, s.model @@ -308,7 +334,7 @@ class Runner: ctx = s.context if ctx: args += ["--context", str(ctx)] - args += ["--vision", {"off": "no", "on": "yes"}.get(s.vision, s.vision)] + args += ["--vision", self.vision_word()] if s.kv: args += ["--kv", s.kv] if fam in ("qwen", "coder"): @@ -351,8 +377,14 @@ class Runner: return 0.0 try: 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)): - return 0.0 + 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) + return 0.9 if (s.vision != "off" and (desc.get("images") or "off") == "off") else 0.0 row = next((r for r in self.catalog.rows() if r.family == s.family and r.model == s.model), None) return float(row.download_gb) if row else 0.0 except Exception: # noqa: BLE001 @@ -424,6 +456,7 @@ class Runner: raise LaunchError("Setup finished but no run config was written for this model.", "Run `strata launch` again; if it repeats, the setup output above says why.", 6) self.emit("model", f"{title} is ready.", 100) + self.check_pictures(path) return path def adopt_prepared_files(self, setup_error: str) -> Path | None: diff --git a/strata_cli/launch/screens.py b/strata_cli/launch/screens.py index 14a2770e..ef87b029 100644 --- a/strata_cli/launch/screens.py +++ b/strata_cli/launch/screens.py @@ -600,8 +600,26 @@ class FolderScreen(Base): out.append(f" Not enough for {need:.0f} GB. You can still go on, but the download is likely to stop; pick a bigger drive.", style=WARN) else: out.append("The free space of that folder could not be read.", style=MUTE) + moving = self.models_that_would_move(value) + if moving: + out.append(f"\nModel files Strata already keeps in {moving} are moved into this folder when you start " + "(quick on the same drive; on another drive they stay where they are and are used from there).", style=WARN) self.query_one("#folderinfo", Static).update(out) + def models_that_would_move(self, value: str) -> str | None: + """The folder holding model files today when a different one is typed (setup gathers the model files into the data folder), else None.""" + try: + old = Path(self.ctx.catalog.data_dir()) + new = Path(value).expanduser() if value else old + if os.path.normcase(str(new.resolve())) == os.path.normcase(str(old.resolve())): + return None + models = old / "models" + if models.is_dir() and any(models.iterdir()): + return str(old) + except OSError: + pass + return None + def explain(self) -> Text: return Text("Models are large files. Strata keeps them in one folder; the default is Strata's own data folder. " "Press Enter to keep it, or type another folder (it is created if it does not exist).", style=MUTE) @@ -748,13 +766,22 @@ class PicturesScreen(Base): s = self.ctx.settings return next((x for x in self.ctx.rows if (x.family, x.model) == (s.family, s.model)), None) + def reader(self) -> str: + """"present" when the installed engine carries the picture reader (strata-vision), "missing" when an engine is installed without it, + "unknown" before any engine is installed (the first launch fetches it).""" + exe = self.ctx.engine_exe() + if not exe: + return "unknown" + folder = Path(str(exe)).parent + return "present" if any((folder / n).is_file() for n in ("strata-vision", "strata-vision.exe")) else "missing" + def on_mount(self) -> None: s = self.ctx.settings r = self.row() self.supported = True if r is None else r.images items = [Item(["No pictures"], key="off")] if self.supported: - items.append(Item(["Yes, read pictures"], key="on")) + items.append(Item(["Yes, read pictures" + (" (this engine has no picture reader)" if self.reader() == "missing" else "")], key="on")) else: items.append(Item([Cell("Yes, read pictures: not available for this model yet", MUTE)], key="on", enabled=False)) sel = 1 if s.vision != "off" and self.supported else 0 @@ -768,7 +795,12 @@ class PicturesScreen(Base): if vram < 24 else "a 0.9 GB download, and about 1.4 GB of graphics memory kept free for the picture reader (text is a few % slower).") if not self.supported: return Text("This model cannot read pictures yet, so pictures stay off. Pick another model if you need them.", style=WARN) - return Text("Pictures add " + extra + " Say No if you only chat in text.", style=MUTE) + out = Text("Pictures add " + extra + " Say No if you only chat in text.", style=MUTE) + if self.reader() == "missing": + out.append("\nHeads up: the engine installed here does not carry the picture reader, so the model would answer text only. " + "Update the engine, or say No.", style=WARN) + return out + return out def commit(self) -> None: self.ctx.settings.vision = self.menu().current.key diff --git a/tests/terminal/test_launch.py b/tests/terminal/test_launch.py index 6012a07b..9c41faba 100644 --- a/tests/terminal/test_launch.py +++ b/tests/terminal/test_launch.py @@ -404,6 +404,72 @@ class AdoptRules(unittest.TestCase): family_def={}, log=h.base / "x.log", backend=None) self.assertIn("only for the Qwen3.8-Flash-Next", problems[0]) + def test_pictures_on_is_setups_yes_and_setup_picks_the_encoder(self): + with Home() as h: + cat = catalog(HW_12) + for vision, want in (("on", "yes"), ("off", "no"), ("gpu", "gpu"), ("cpu", "cpu")): + r = Runner(S.LaunchSettings(family="qwen", model="IQ3_XXS", vision=vision), catalog=cat) + self.assertEqual(r.vision_word(), want, vision) + argv = Runner(S.LaunchSettings(family="qwen", model="IQ3_XXS", vision="on"), catalog=cat).setup_args() + self.assertEqual(argv[argv.index("--vision") + 1], "yes") + + def test_setup_control_mode_keeps_pictures_when_the_engine_carries_the_reader(self): + from types import SimpleNamespace + with Home() as h: + mod = catalog(HW_12).strata.setup_module() + if mod is None or not hasattr(mod, "control_engine_step"): + self.skipTest("no setup.py in this checkout") + engine = h.base / "engine" + engine.mkdir() + found = SimpleNamespace(root=engine, version="0.1.45", backend="cuda", platform="linux-x86_64") + with mock.patch.object(mod, "get_llama_cpp", return_value=engine), mock.patch("strata_control.engine_component.resolve", return_value=found): + self.assertEqual(mod.control_engine_step({}, "cpu")[5], "none") # no strata-vision beside the engine: off, with a note + (engine / mod.VEXE).write_text("x") + self.assertEqual(mod.control_engine_step({}, "cpu")[5], "cpu") # the component carries it: the choice is kept + self.assertEqual(mod.control_engine_step({}, "none")[5], "none") + + def test_turning_pictures_on_for_an_installed_model_downloads_only_the_reader(self): + with Home() as h: + cat = catalog(HW_12) + cfgfile = h.base / "strata-x.json" + cfgfile.write_text("{}") + for vision, images, ctx, want in (("on", "off", 32768, 0.9), ("on", "cpu", 32768, 0.0), ("off", "off", 32768, 0.0), ("off", "off", 65536, 0.0)): + r = Runner(S.LaunchSettings(family="qwen", model="IQ3_XXS", vision=vision, context=ctx), catalog=cat) + desc = {"context": 32768, "kv": "int8", "images": images} + 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) + seen = [] + r = Runner(S.LaunchSettings(family="qwen", model="IQ3_XXS", vision="on"), catalog=cat, emit=seen.append) + path = h.base / "cfg.json" + path.write_text("{}") + with mock.patch.object(cat.strata, "describe_config", return_value={"images": "off"}): + r.check_pictures(path) + self.assertTrue(any("Pictures could not be switched on" in e.text and e.level == "warn" for e in seen)) + seen.clear() + with mock.patch.object(cat.strata, "describe_config", return_value={"images": "cpu"}): + r.check_pictures(path) + self.assertEqual(seen, []) + def test_runner_adopts_when_setup_cannot_handle_the_card(self): with Home() as h: d, m = self.files(h.base) diff --git a/tests/terminal/test_launch_tui.py b/tests/terminal/test_launch_tui.py index 7f4dba42..87f33650 100644 --- a/tests/terminal/test_launch_tui.py +++ b/tests/terminal/test_launch_tui.py @@ -315,6 +315,22 @@ class FolderStep(Base): self.assertIn("How much text should it remember at once?", text_of(app)) self.run_app(case) + def test_a_new_folder_says_that_the_models_already_stored_will_move(self): + async def case(app, pilot, ctx): + old = self.home.base / "old-data" + (old / "models" / "Q2_0").mkdir(parents=True) + (old / "models" / "Q2_0" / "x.gguf").write_text("x") + with mock.patch.object(type(ctx.catalog), "data_dir", return_value=old): + await press(pilot, "enter", "enter") + self.assertNotIn("are moved into this folder", text_of(app)) + f = app.screen.query_one("#folderpath") + f.value = "" + await typed(pilot, str(self.home.base / "new-data")) + t = " ".join(text_of(app).replace("\n", " ").split()) + self.assertIn("Model files Strata already keeps in", t) + self.assertIn("are moved into this folder when you start", t) + self.run_app(case) + def test_keeping_the_default_stores_nothing(self): async def case(app, pilot, ctx): await press(pilot, "enter", "enter", "enter")