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++
Terminal: 'already downloaded' for a model on disk; strata monitor finds a running launch without --url (K)
Niko12217f037f4451af
diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.pyindex c7d03a22c..297508a53 100644--- a/strata_cli/launch/runner.py+++ b/strata_cli/launch/runner.py@@ -275,6 +275,14 @@ def launch_dir() -> Path:# ----------------------------------------------------------------------------------------------- the runner++def download_text(dl: dict, already: bool) -> str:+ """The step line for the model download. A model whose files were all on disk before this run says so instead of "Downloading 58.5 of 58.5 GB"."""+ if already:+ return f"Model already downloaded ({dl['total_gb']:.1f} GB), checking the files"+ return f"Downloading {dl['done_gb']:.1f} of {dl['total_gb']:.1f} GB"++class Runner:def __init__(self, s: S.LaunchSettings, *, catalog: Catalog | None = None, emit: Callable[[Event], None] | None = None,cancel: threading.Event | None = None, feed: str | None = None, python: str | None = None,@@ -602,6 +610,7 @@ class Runner:env["PYTHONPATH"] = str(cat.src)p = self._spawn(argv, env=env, cwd=str(cat.src))lines: list[str] = []+ already: bool | None = None # all the model's files were on disk before this run wrote anythingfolder = str(cat.data_dir() / "models" / cat.tag_of(s.family, s.model))total = float(next((r.download_gb for r in cat.rows() if r.family == s.family and r.model == s.model), 0) or 0)for line in p.stdout: # type: ignore[union-attr]@@ -617,7 +626,10 @@ class Runner:prog = cat.mcp.combined_progress(prog, {"folder": folder, "total_gb": total})dl = prog.get("download")if dl and not s.model_path and dl.get("total_gb", 0) >= 0.05:- self.emit("model", f"Downloading {dl['done_gb']:.1f} of {dl['total_gb']:.1f} GB", float(dl["percent"]), step=prog.get("step"))+ if already is None:+ already = float(dl["percent"]) >= 99.5+ text = download_text(dl, already)+ self.emit("model", text, float(dl["percent"]), step=prog.get("step"))elif prog.get("step"):self.emit("model", f"Setup step {prog['step']}", None, step=prog.get("step"))code = p.wait()diff --git a/strata_cli/monitor_commands.py b/strata_cli/monitor_commands.pyindex 6414eeaac..24b4a420a 100644--- a/strata_cli/monitor_commands.py+++ b/strata_cli/monitor_commands.py@@ -33,6 +33,19 @@ def add_status(sp: argparse._SubParsersAction) -> None:status.add_argument("--quiet", action="store_true", help="suppress human informational output")+def running_launch() -> dict | None:+ """The server a `strata launch` has running (address and its key), when no address was given: so `strata monitor` needs no --url.+ Nothing is read when a connection, STRATA_URL or STRATA_CONNECTION names the server, and a thin monitor bundle has no launch code."""+ if os.environ.get("STRATA_URL") or os.environ.get("STRATA_CONNECTION"):+ return None+ try:+ from strata_cli.launch.cmd import launch_info+ info = launch_info()+ except Exception: # noqa: BLE001 - no launch code, no profiles: use the default address+ return None+ return info if info and info.get("running") and info.get("url") else None++def add_monitor(sp: argparse._SubParsersAction) -> None:monitor = sp.add_parser("monitor", help="read-only terminal monitor: seven views (Overview ... Logs, Connect), the same as the one strata launch opens")_connection(monitor)@@ -171,9 +184,10 @@ def run(a: argparse.Namespace) -> int:return _error("JSON monitor output requires --once; interactive monitor uses a terminal", 2, machine)if a.command == "monitor" and not a.once and not sys.stdout.isatty():return _error("interactive monitor needs a terminal; use --once or strata status --json", 2, machine)- resolved = connections.resolve(url=a.url, connection=a.connection,+ found = running_launch() if a.command == "monitor" and not (a.url or a.connection) else None+ resolved = connections.resolve(url=found["url"] if found else a.url, connection=a.connection,credential_env=a.credential_env, timeout=a.timeout)- endpoint = Endpoint(resolved["url"], os.environ.get(resolved["credential_env"]),+ endpoint = Endpoint(resolved["url"], os.environ.get(resolved["credential_env"]) or (found or {}).get("key"),resolved["timeout_s"], resolved["prefix"])if a.command == "logs":from strata_cli.logs import run as run_logsdiff --git a/tests/terminal/test_terminal_polish.py b/tests/terminal/test_terminal_polish.pynew file mode 100644index 000000000..6ff558a92--- /dev/null+++ b/tests/terminal/test_terminal_polish.py@@ -0,0 +1,56 @@+"""Terminal polish (0.2.1): "already downloaded" instead of a fake download, and `strata monitor` finding a running launch."""++import io+import json+import os+import unittest+from contextlib import redirect_stdout+from unittest import mock++from strata_cli.cli import main+from strata_cli.launch.runner import download_text+++class AlreadyDownloaded(unittest.TestCase):+ def test_a_model_on_disk_is_not_called_a_download(self):+ dl = {"done_gb": 58.5, "total_gb": 58.5, "percent": 100.0}+ self.assertEqual(download_text(dl, True), "Model already downloaded (58.5 GB), checking the files")++ def test_a_real_download_keeps_its_numbers(self):+ dl = {"done_gb": 12.0, "total_gb": 58.5, "percent": 20.5}+ self.assertEqual(download_text(dl, False), "Downloading 12.0 of 58.5 GB")+++class MonitorFindsLaunch(unittest.TestCase):+ def _run(self, argv, info, env=None):+ with mock.patch.dict(os.environ, env or {}, clear=False), \+ mock.patch("strata_cli.launch.cmd.launch_info", return_value=info), \+ mock.patch("strata_cli.monitor_commands.Endpoint") as endpoint:+ os.environ.pop("STRATA_URL", None) if not env else None+ endpoint.return_value.snapshot.return_value = {"schema_version": 1}+ out = io.StringIO()+ with redirect_stdout(out):+ main(argv)+ return endpoint++ def test_no_url_uses_the_running_launch_and_its_key(self):+ info = {"running": True, "url": "http://127.0.0.1:8080", "key": "launch-key"}+ with mock.patch.dict(os.environ, {}, clear=False):+ os.environ.pop("STRATA_API_KEY", None)+ endpoint = self._run(["monitor", "--once", "--quiet"], info)+ args = endpoint.call_args[0]+ self.assertEqual(args[0], "http://127.0.0.1:8080")+ self.assertEqual(args[1], "launch-key")++ def test_an_explicit_url_wins(self):+ info = {"running": True, "url": "http://127.0.0.1:8080", "key": "k"}+ endpoint = self._run(["monitor", "--once", "--quiet", "--url", "http://127.0.0.1:9999"], info)+ self.assertEqual(endpoint.call_args[0][0], "http://127.0.0.1:9999")++ def test_nothing_running_keeps_the_default_address(self):+ endpoint = self._run(["monitor", "--once", "--quiet"], None)+ self.assertEqual(endpoint.call_args[0][0], "http://127.0.0.1:8095")+++if __name__ == "__main__":+ unittest.main()