Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

fix(ui): remove the Web UI plugin registry nothing rendered (#1465) (#1608)

Srinivasan R57ac51689acb
diff --git a/changelog.d/0.75.1/1608.removed.md b/changelog.d/0.75.1/1608.removed.md
new file mode 100644
index 00000000..d3a98879
--- /dev/null
+++ b/changelog.d/0.75.1/1608.removed.md
@@ -0,0 +1 @@
+- The Web UI plugin registry, `soup_cli.ui.plugins` (`register_tab`, `list_tabs`, `get_tab`, `clear_tabs`, `load_plugins`, `TabSpec`), is removed, and with it the "Web UI Plugin Registry + Env Knobs" section of `docs/serving-and-export.md`. The module has been importable since v0.44.0, so `from soup_cli.ui.plugins import ...` stops working; no rendered feature is lost, because `create_app` never read the registry and a registered tab was never shown. `soup plugins` (`soup_cli.plugins`) is a different feature and is unchanged (#1465 by @Srinivasan8888 in #1608).
diff --git a/docs/serving-and-export.md b/docs/serving-and-export.md
index bd77023e..e936fe98 100644
--- a/docs/serving-and-export.md
+++ b/docs/serving-and-export.md
@@ -16,7 +16,6 @@
- [Soup Quantize — Ergonomic Export Alias](#soup-quantize--ergonomic-export-alias)
- [Llama.cpp Proxy](#llamacpp-proxy)
- [Tail-Latency Stats + Tool-Call Timer](#tail-latency-stats--tool-call-timer)
-- [Web UI Plugin Registry + Env Knobs](#web-ui-plugin-registry--env-knobs)
- [Deploy Autopilot](#deploy-autopilot)
- [Agent Forge](#agent-forge)
- [HF Space SDK Auto-Pick](#hf-space-sdk-auto-pick)
@@ -751,21 +750,6 @@ with ToolCallTimer(buffer, name="fetch_url") as timer:
Pure-Python EMA + linear-interp percentiles (DoS cap: `MAX_SAMPLES=1_000_000`). `ToolOutputsBuffer` is a thread-safe `collections.deque(maxlen=1000)` ring with truncated previews; `ToolCallTimer` records duration / output / error per invocation for tool-calling SFT runs.
-## Web UI Plugin Registry + Env Knobs
-
-```python
-# src/soup_cli/ui/plugins/my_tab.py
-from soup_cli.ui.plugins import register_tab
-
-def render_my_tab(request) -> str:
- return "<div>my tab body</div>"
-
-register_tab(name="my-tab", title="My Tab", render=render_my_tab)
-```
-
-Drop-in plugin registry with kebab-case name allowlist, 32-tab cap, idempotent re-register. Plus `API_HOST` / `API_PORT` / `API_KEY` / `GRADIO_HOST` / `GRADIO_PORT` env knobs for FastAPI + Gradio surfaces.
-
-
## Deploy Autopilot
Pick the optimal PEFT + quantisation + speculative-decoding combo for your hardware target in one command:
diff --git a/src/soup_cli/ui/plugins/__init__.py b/src/soup_cli/ui/plugins/__init__.py
deleted file mode 100644
index 0c18d8c2..00000000
--- a/src/soup_cli/ui/plugins/__init__.py
+++ /dev/null
@@ -1,118 +0,0 @@
-"""v0.44.0 Part C — Web UI plugin registry.
-
-Drop-in `soup_cli/ui/plugins/*.py` files register tabs by calling
-`register_tab(...)` at import time. The FastAPI app discovers them via
-`load_plugins()` at startup.
-
-Plugin contract:
-
-```python
-from soup_cli.ui.plugins import register_tab
-
-def render_my_tab(request) -> str:
- return "<div>my tab body</div>"
-
-register_tab(name="my-tab", title="My Tab", render=render_my_tab)
-```
-
-Pure-Python: no FastAPI dep at module level.
-"""
-
-from __future__ import annotations
-
-import importlib
-import logging
-import pkgutil
-import re
-from dataclasses import dataclass
-from threading import Lock
-from types import MappingProxyType
-from typing import Callable, Dict, Mapping, Optional
-
-logger = logging.getLogger(__name__)
-
-# Tab name regex — kebab-case, alphanumeric + hyphen.
-_TAB_NAME_RE = re.compile(r"^[a-z0-9][a-z0-9\-]{0,30}$")
-_MAX_TITLE_LEN = 64
-_MAX_TABS = 32
-
-_TABS: Dict[str, "TabSpec"] = {}
-_LOCK = Lock()
-
-
-@dataclass(frozen=True)
-class TabSpec:
- """One registered Web UI tab."""
-
- name: str
- title: str
- render: Callable[..., str]
-
-
-def register_tab(
- *,
- name: str,
- title: str,
- render: Callable[..., str],
-) -> TabSpec:
- """Register a tab. Idempotent for identical (title, render); rejects
- re-registration with a different title or render fn."""
- if not isinstance(name, str) or not _TAB_NAME_RE.match(name):
- raise ValueError(
- "name must be kebab-case ([a-z0-9][a-z0-9-]{0,30})"
- )
- if not isinstance(title, str) or not title or "\x00" in title:
- raise ValueError("title must be a non-empty NUL-free str")
- if len(title) > _MAX_TITLE_LEN:
- raise ValueError(f"title exceeds {_MAX_TITLE_LEN} chars")
- if not callable(render):
- raise TypeError("render must be callable")
- spec = TabSpec(name=name, title=title, render=render)
- with _LOCK:
- if len(_TABS) >= _MAX_TABS and name not in _TABS:
- raise RuntimeError(f"too many tabs (max {_MAX_TABS})")
- existing = _TABS.get(name)
- if existing is not None and (
- existing.title != title or existing.render is not render
- ):
- raise ValueError(
- f"tab name {name!r} already registered with a different spec"
- )
- _TABS[name] = spec
- return spec
-
-
-def list_tabs() -> Mapping[str, TabSpec]:
- """Return an immutable view of currently-registered tabs."""
- with _LOCK:
- return MappingProxyType(dict(_TABS))
-
-
-def get_tab(name: str) -> Optional[TabSpec]:
- if not isinstance(name, str):
- return None
- with _LOCK:
- return _TABS.get(name)
-
-
-def clear_tabs() -> None:
- """Remove all registered tabs. Used by tests."""
- with _LOCK:
- _TABS.clear()
-
-
-def load_plugins() -> int:
- """Import every `soup_cli.ui.plugins.*` submodule. Returns count loaded."""
- count = 0
- pkg = importlib.import_module(__name__)
- for module_info in pkgutil.iter_modules(pkg.__path__):
- if module_info.name.startswith("_"):
- continue
- try:
- importlib.import_module(f"{__name__}.{module_info.name}")
- count += 1
- except Exception: # noqa: BLE001 — plugin failure must not crash UI
- logger.exception(
- "Failed to load Web UI plugin: %s", module_info.name
- )
- return count
diff --git a/tests/test_issue1465_ui_plugin_registry_removed.py b/tests/test_issue1465_ui_plugin_registry_removed.py
new file mode 100644
index 00000000..2394c745
--- /dev/null
+++ b/tests/test_issue1465_ui_plugin_registry_removed.py
@@ -0,0 +1,142 @@
+"""#1465: the Web UI plugin registry is gone, and nothing still names it.
+
+``soup_cli.ui.plugins`` (``register_tab`` and friends, importable since v0.44.0) was a
+registry nobody read: ``create_app`` never imported it, no route and nothing in
+``ui/static/`` listed the registered tabs, and ``docs/serving-and-export.md`` promised a
+drop-in tab that was never rendered. The maintainer's ruling on #1465 was to remove it
+rather than wire it. ``soup_cli.plugins`` (``soup plugins``, the working plugin system)
+and ``utils/ui_env.py`` are untouched.
+"""
+
+from __future__ import annotations
+
+import importlib
+import re
+from pathlib import Path
+
+import pytest
+
+_ROOT = Path(__file__).resolve().parents[1]
+_SRC = _ROOT / "src"
+_DOCS = _ROOT / "docs"
+
+#: The spellings the removed registry went by. ``soup_cli.plugins`` (no ``ui``) is a
+#: different, working feature and is deliberately not in this list.
+_REGISTRY_MARKERS = (
+ "soup_cli.ui.plugins",
+ "soup_cli/ui/plugins",
+ "register_tab",
+ "Web UI Plugin Registry",
+)
+
+#: The public names of the removed module.
+_REMOVED_NAMES = ("register_tab", "list_tabs", "get_tab", "clear_tabs", "load_plugins", "TabSpec")
+
+#: Every route ``ui/app.py`` declares with a decorator, plus the ``/static`` mount, read
+#: before the removal. FastAPI's own documentation routes (``/docs``, ``/redoc``,
+#: ``/openapi.json``) are left out: ``create_app`` turns them on only for a loopback host.
+_ROUTES_TODAY = {
+ "/",
+ "/static",
+ "/api/health",
+ "/api/auth/ticket",
+ "/api/chat/send",
+ "/api/tool-outputs",
+ "/api/train/stream",
+ "/api/runs",
+ "/api/runs/compare",
+ "/api/runs/{run_id}",
+ "/api/runs/{run_id}/metrics",
+ "/api/runs/{run_id}/eval",
+ "/api/system",
+ "/api/templates",
+ "/api/config/validate",
+ "/api/config/schema",
+ "/api/config/from-form",
+ "/api/train/start",
+ "/api/train/status",
+ "/api/train/stop",
+ "/api/train/logs",
+ "/api/train/metrics/live",
+ "/api/train/progress",
+ "/api/data/inspect",
+ "/api/recipes",
+}
+
+
+def _files(root: Path, suffixes: tuple[str, ...]):
+ for path in sorted(root.rglob("*")):
+ if path.is_file() and path.suffix in suffixes and "__pycache__" not in path.parts:
+ yield path
+
+
+class TestTheRegistryIsGone:
+ def test_the_module_cannot_be_imported(self):
+ # A checkout that ran the old tests keeps an ignored plugins/__pycache__/ after the
+ # pull, and Python then imports the directory as an empty namespace package.
+ try:
+ module = importlib.import_module("soup_cli.ui.plugins")
+ except ModuleNotFoundError:
+ return
+ assert module.__spec__.origin is None, module.__spec__.origin
+ assert [name for name in _REMOVED_NAMES if hasattr(module, name)] == []
+
+ def test_no_source_file_is_left_in_the_package_directory(self):
+ plugins_dir = _SRC / "soup_cli" / "ui" / "plugins"
+ leftovers = (
+ sorted(
+ str(path.relative_to(plugins_dir))
+ for path in plugins_dir.rglob("*")
+ if path.is_file() and "__pycache__" not in path.parts
+ )
+ if plugins_dir.is_dir()
+ else []
+ )
+ assert leftovers == []
+
+ def test_nothing_under_src_names_it(self):
+ hits = [
+ f"{path.relative_to(_ROOT)}: {marker}"
+ for path in _files(_SRC, (".py", ".html", ".js", ".css", ".md"))
+ for marker in _REGISTRY_MARKERS
+ if marker in path.read_text(encoding="utf-8", errors="replace")
+ ]
+ assert hits == [], hits
+
+ def test_nothing_under_docs_names_it(self):
+ hits = [
+ f"{path.relative_to(_ROOT)}: {marker}"
+ for path in _files(_DOCS, (".md",))
+ for marker in _REGISTRY_MARKERS
+ if marker in path.read_text(encoding="utf-8")
+ ]
+ assert hits == [], hits
+
+ def test_the_docs_contents_list_has_no_dangling_anchor(self):
+ """The section and its contents-list line go together: a surviving
+ ``(#web-ui-plugin-registry--env-knobs)`` entry would point at nothing."""
+ text = (_DOCS / "serving-and-export.md").read_text(encoding="utf-8")
+ assert "web-ui-plugin-registry" not in text
+ assert not re.search(r"^## .*Plugin Registry", text, re.M)
+
+
+class TestNothingElseMoved:
+ def test_the_working_plugin_system_is_still_there(self):
+ """``soup plugins`` is a different feature and the README's one mention of
+ plugins points at it; it must not be caught in this removal."""
+ plugins = importlib.import_module("soup_cli.plugins")
+ assert callable(plugins.load_plugins)
+ assert "Plugin System" in (_DOCS / "backends-and-ops.md").read_text(encoding="utf-8")
+
+ def test_ui_env_is_untouched(self):
+ from soup_cli.utils.ui_env import UiEnv, resolve_ui_env
+
+ assert resolve_ui_env({}) == UiEnv(None, None, None, None, None)
+
+ def test_the_web_ui_still_serves_todays_routes(self):
+ pytest.importorskip("fastapi")
+ from soup_cli.ui.app import create_app
+
+ served = {getattr(route, "path", None) for route in create_app().routes}
+ missing = _ROUTES_TODAY - served
+ assert not missing, sorted(missing)
diff --git a/tests/test_v0440_part_c.py b/tests/test_v0440_part_c.py
index 19bcb879..e91731de 100644
--- a/tests/test_v0440_part_c.py
+++ b/tests/test_v0440_part_c.py
@@ -1,90 +1,16 @@
-"""v0.44.0 Part C — UI plugin registry + env knob tests."""
+"""v0.44.0 Part C — UI env knob tests.
+
+The UI plugin registry (``soup_cli.ui.plugins``) that this file also covered was
+removed in #1465: nothing rendered a registered tab. Its tests went with it; the
+``resolve_ui_env`` tests stay (``utils/ui_env.py`` is a separate question).
+"""
from __future__ import annotations
import pytest
-from soup_cli.ui.plugins import (
- clear_tabs,
- get_tab,
- list_tabs,
- register_tab,
-)
from soup_cli.utils.ui_env import UiEnv, resolve_ui_env
-
[email protected](autouse=True)
-def _clean_tabs():
- """Each test starts with an empty tab registry."""
- clear_tabs()
- yield
- clear_tabs()
-
-
-# --- plugin registry --------------------------------------------------------
-
-def test_register_tab_happy():
- spec = register_tab(name="my-tab", title="My Tab", render=lambda: "hi")
- assert spec.name == "my-tab"
- assert spec.title == "My Tab"
- assert get_tab("my-tab") is spec
-
-
-def test_register_tab_immutable_view():
- register_tab(name="t1", title="T1", render=lambda: "x")
- snapshot = list_tabs()
- with pytest.raises(TypeError):
- snapshot["x"] = None # type: ignore[index]
-
-
-def test_register_tab_rejects_invalid_name():
- with pytest.raises(ValueError):
- register_tab(name="Bad Name", title="x", render=lambda: "y")
- with pytest.raises(ValueError):
- register_tab(name="-leading", title="x", render=lambda: "y")
- with pytest.raises(ValueError):
- register_tab(name="x" * 99, title="x", render=lambda: "y")
-
-
-def test_register_tab_rejects_invalid_title():
- with pytest.raises(ValueError):
- register_tab(name="t", title="", render=lambda: "x")
- with pytest.raises(ValueError):
- register_tab(name="t", title="bad\x00", render=lambda: "x")
- with pytest.raises(ValueError):
- register_tab(name="t", title="x" * 200, render=lambda: "x")
-
-
-def test_register_tab_rejects_non_callable_render():
- with pytest.raises(TypeError):
- register_tab(name="t", title="x", render="not callable") # type: ignore[arg-type]
-
-
-def test_register_tab_idempotent_for_same_spec():
- fn = lambda: "y" # noqa: E731
- spec1 = register_tab(name="t", title="T", render=fn)
- spec2 = register_tab(name="t", title="T", render=fn)
- assert spec1 == spec2
-
-
-def test_register_tab_rejects_re_register_with_different_spec():
- register_tab(name="t", title="T", render=lambda: "x")
- with pytest.raises(ValueError, match="already registered"):
- register_tab(name="t", title="OTHER", render=lambda: "y")
-
-
-def test_register_tab_too_many():
- for idx in range(32):
- register_tab(name=f"t{idx}", title=f"T{idx}", render=lambda: "x")
- with pytest.raises(RuntimeError, match="too many tabs"):
- register_tab(name="overflow", title="x", render=lambda: "x")
-
-
-def test_get_tab_unknown_returns_none():
- assert get_tab("nope") is None
- assert get_tab(123) is None # type: ignore[arg-type]
-
-
# --- UI env knobs -----------------------------------------------------------
def test_resolve_ui_env_empty():
diff --git a/tests/test_v0440_review_followups.py b/tests/test_v0440_review_followups.py
index 62af4eea..e54114dd 100644
--- a/tests/test_v0440_review_followups.py
+++ b/tests/test_v0440_review_followups.py
@@ -14,12 +14,6 @@ import threading
import pytest
from soup_cli.commands.llama import _LLAMA_ENV_ALLOWLIST, _filtered_env
-from soup_cli.ui.plugins import (
- clear_tabs,
- list_tabs,
- load_plugins,
- register_tab,
-)
from soup_cli.utils.checkpoint_trigger import write_trigger
from soup_cli.utils.delinearize_llama4 import discover_weight_files
from soup_cli.utils.fetch_examples import fetch_examples_dir
@@ -189,25 +183,6 @@ def test_render_qr_ascii_rejects_non_string():
render_qr_ascii(123) # type: ignore[arg-type]
-# --- ui plugins -------------------------------------------------------------
-
-def test_load_plugins_returns_int(monkeypatch):
- clear_tabs()
- count = load_plugins()
- assert isinstance(count, int)
- # No bundled plugins ship in v0.44.0 — count is 0.
- assert count == 0
-
-
-def test_register_tab_clear_resets_limit():
- clear_tabs()
- for idx in range(32):
- register_tab(name=f"t{idx}", title="T", render=lambda: "x")
- clear_tabs()
- register_tab(name="fresh", title="T", render=lambda: "x")
- assert "fresh" in list_tabs()
-
-
# --- ui_env -----------------------------------------------------------------
def test_resolve_ui_env_default_reads_environ(monkeypatch):