Personal AI, On Personal Devices
Python
fix(cli): report Ollama pull streaming errors (#1007)
Johnny C Watt0eb7811df96c
diff --git a/src/openjarvis/cli/model.py b/src/openjarvis/cli/model.pyindex 46247d83..a146abc1 100644--- a/src/openjarvis/cli/model.py+++ b/src/openjarvis/cli/model.py@@ -173,6 +173,9 @@ def ollama_pull(host: str, model_name: str, console: Console) -> bool:data = json.loads(line)except Exception:continue+ if "error" in data:+ console.print(f"Ollama error: {data['error']}", markup=False)+ return Falsestatus = data.get("status", "")if "total" in data and "completed" in data:total = data["total"]diff --git a/tests/cli/test_model_pull.py b/tests/cli/test_model_pull.pyindex 13f74067..92a143a8 100644--- a/tests/cli/test_model_pull.py+++ b/tests/cli/test_model_pull.py@@ -2,17 +2,41 @@from __future__ import annotations+import io+from contextlib import closingfrom unittest import mock+import httpxfrom click.testing import CliRunnerfrom rich.console import Consolefrom openjarvis.cli.model import ollama_pull+from openjarvis.core.config import JarvisConfigclass TestOllamaPull:"""Test the extracted ollama_pull helper."""+ def test_ollama_pull_stream_error(self) -> None:+ output = io.StringIO()+ response = httpx.Response(+ 200,+ request=httpx.Request("POST", "http://localhost:11434/api/pull"),+ content=(+ b'{"status":"pulling manifest"}\n'+ b'{"error":"download failed [red]disk full[/red]"}\n'+ ),+ )+ with mock.patch("httpx.stream", return_value=closing(response)):+ result = ollama_pull(+ "http://localhost:11434", "qwen3.5:2b", Console(file=output)+ )++ assert result is False+ assert "download failed [red]disk full[/red]" in output.getvalue()+ assert "Successfully pulled" not in output.getvalue()+ assert response.is_closed+def test_ollama_pull_success(self) -> None:import io@@ -46,6 +70,26 @@ class TestOllamaPull:class TestPullCliMultiEngine:"""Test the pull CLI command dispatches to correct engine."""+ def test_pull_ollama_stream_error_exits_unsuccessfully(self) -> None:+ from openjarvis.cli import cli++ response = httpx.Response(+ 200,+ request=httpx.Request("POST", "http://localhost:11434/api/pull"),+ content=b'{"status":"pulling manifest"}\n{"error":"disk full"}\n',+ )+ with (+ mock.patch("openjarvis.cli.model.load_config", return_value=JarvisConfig()),+ mock.patch("httpx.stream", return_value=closing(response)),+ ):+ result = CliRunner().invoke(+ cli, ["model", "pull", "qwen3.5:2b", "--engine", "ollama"]+ )++ assert result.exit_code == 1+ assert "disk full" in result.output+ assert "Successfully pulled" not in result.output+def test_pull_llamacpp_uses_huggingface_cli(self) -> None:from openjarvis.cli import cli