Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: update the NPU runtime, harden its pin updates, and polish the NPU UI (#16834)

oobabooga1928a2cd6a96
diff --git a/scripts/update_lemonade_pins.py b/scripts/update_lemonade_pins.py
index 80993128c1e..751e03bdae8 100644
--- a/scripts/update_lemonade_pins.py
+++ b/scripts/update_lemonade_pins.py
@@ -4,6 +4,9 @@
"""Move studio/lemonade_prebuilt_pins.json to the latest stable Lemonade and FastFlowLM releases.
+A release whose Linux build needs a system library newer than LINUX_ABI_LIMITS is skipped for the
+newest one that does not, since a lemond that cannot start breaks the NPU for every Linux user on that distro.
+
Exit codes: 0 = current (or updated with --write); 1 = --check found a newer release; 2 = error.
"""
@@ -13,7 +16,10 @@ import argparse
import hashlib
import json
import os
+import re
import sys
+import tarfile
+import tempfile
import urllib.request
from pathlib import Path
from typing import Callable, Optional
@@ -22,6 +28,16 @@ PINS_PATH = Path(__file__).resolve().parents[1] / "studio" / "lemonade_prebuilt_
_API = "https://api.github.com"
_TIMEOUT_S = 60
_CHUNK = 1 << 20
+# Newest symbol versions Ubuntu 24.04 ships; FastFlowLM's own Linux build already needs glibc 2.39.
+LINUX_ABI_LIMITS = {
+ "GLIBC": (2, 39),
+ "GLIBCXX": (3, 4, 33),
+ "CXXABI": (1, 3, 15),
+ "OPENSSL": (3, 0, 9),
+}
+_SYMBOL_VERSION = re.compile(rb"(GLIBCXX|GLIBC|CXXABI|OPENSSL)_(\d+(?:\.\d+)+)")
+Needs = dict[str, tuple[int, ...]]
+_NEXT_PAGE = re.compile(r'<([^>]+)>;\s*rel="next"')
def _lemonade_assets(version: str) -> dict[str, str]:
@@ -54,22 +70,53 @@ def _request(url: str) -> urllib.request.Request:
return urllib.request.Request(url, headers = headers)
-def fetch_latest_release(repo: str) -> dict:
- """The latest stable release; GitHub's /latest skips drafts and prereleases."""
- with urllib.request.urlopen(
- _request(f"{_API}/repos/{repo}/releases/latest"), timeout = _TIMEOUT_S
- ) as r:
- return json.load(r)
-
-
-def hash_asset(url: str) -> tuple[str, int]:
+def fetch_stable_releases(repo: str) -> list[dict]:
+ # Every page: prerelease candidates can push a compatible stable release past the first one.
+ releases, url = [], f"{_API}/repos/{repo}/releases?per_page=100"
+ while url:
+ with urllib.request.urlopen(_request(url), timeout = _TIMEOUT_S) as r:
+ releases += json.load(r)
+ next_page = _NEXT_PAGE.search(r.headers.get("Link") or "")
+ url = next_page.group(1) if next_page else None
+ return [r for r in releases if not r.get("draft") and not r.get("prerelease")]
+
+
+def tar_abi_needs(fileobj) -> Needs:
+ """Newest symbol version per LINUX_ABI_LIMITS library that any ELF file in a .tar.gz references."""
+ newest: Needs = {}
+ with tarfile.open(fileobj = fileobj, mode = "r:gz") as archive:
+ for member in archive:
+ handle = archive.extractfile(member) if member.isfile() else None
+ if handle is None or handle.read(4) != b"\x7fELF":
+ continue
+ for match in _SYMBOL_VERSION.finditer(handle.read()):
+ lib = match.group(1).decode()
+ version = tuple(int(part) for part in match.group(2).split(b"."))
+ newest[lib] = max(newest.get(lib, ()), version)
+ return newest
+
+
+def hash_asset(url: str) -> tuple[str, int, Optional[Needs]]:
+ """sha256, size and, for a Linux tarball, the newest system library versions its binaries need."""
digest = hashlib.sha256()
size = 0
- with urllib.request.urlopen(_request(url), timeout = _TIMEOUT_S) as response:
- while chunk := response.read(_CHUNK):
- digest.update(chunk)
- size += len(chunk)
- return digest.hexdigest(), size
+ with tempfile.TemporaryFile() as tmp:
+ with urllib.request.urlopen(_request(url), timeout = _TIMEOUT_S) as response:
+ while chunk := response.read(_CHUNK):
+ digest.update(chunk)
+ tmp.write(chunk)
+ size += len(chunk)
+ tmp.seek(0)
+ needs = tar_abi_needs(tmp) if url.endswith(".tar.gz") else None
+ return digest.hexdigest(), size, needs
+
+
+class AbiTooNew(RuntimeError):
+ """A release whose Linux build cannot start within LINUX_ABI_LIMITS."""
+
+
+def _dotted(version: tuple[int, ...]) -> str:
+ return ".".join(map(str, version))
def version_key(version: str) -> tuple[int, ...]:
@@ -81,7 +128,10 @@ def version_key(version: str) -> tuple[int, ...]:
def updated_section(
- name: str, section: dict, release: dict, hasher: Callable[[str], tuple[str, int]]
+ name: str,
+ section: dict,
+ release: dict,
+ hasher: Callable[[str], tuple[str, int, Optional[Needs]]],
) -> Optional[dict]:
tag = str(release["tag_name"])
bare = tag[1:] if tag.startswith("v") else tag
@@ -95,7 +145,7 @@ def updated_section(
asset = published.get(asset_name)
if asset is None:
raise RuntimeError(f"{section['repo']} {tag} has no {asset_name}.")
- sha256, size = hasher(asset["browser_download_url"])
+ sha256, size, needs = hasher(asset["browser_download_url"])
github_digest = asset.get("digest")
# Fail closed: without GitHub's digest the hash proves only what this runner downloaded.
if not github_digest:
@@ -106,28 +156,54 @@ def updated_section(
)
if asset.get("size") is not None and asset["size"] != size:
raise RuntimeError(f"{asset_name} is {size} bytes, but GitHub lists {asset['size']}.")
+ too_new = [
+ f"{lib} {_dotted(version)} > {_dotted(LINUX_ABI_LIMITS[lib])}"
+ for lib, version in sorted((needs or {}).items())
+ if version > LINUX_ABI_LIMITS[lib]
+ ]
+ if too_new:
+ raise AbiTooNew(f"{section['repo']} {tag}: {asset_name} needs {', '.join(too_new)}.")
assets[key] = {"name": asset_name, "sha256": sha256}
if with_size:
assets[key]["size"] = size
return {**section, "version": tag if keep_v else bare, "assets": assets}
+def newer_releases(releases: list[dict], pinned: str) -> list[dict]:
+ """Releases with a numeric tag above the pin, newest first."""
+ newer = []
+ for release in releases:
+ try:
+ key = version_key(str(release["tag_name"]))
+ except ValueError:
+ continue
+ if key > version_key(pinned):
+ newer.append((key, release))
+ return [release for _, release in sorted(newer, key = lambda item: item[0], reverse = True)]
+
+
def update_pins(
pins: dict,
- releases: Optional[Callable[[str], dict]] = None,
- hasher: Optional[Callable[[str], tuple[str, int]]] = None,
+ releases: Optional[Callable[[str], list[dict]]] = None,
+ hasher: Optional[Callable[[str], tuple[str, int, Optional[Needs]]]] = None,
only: Optional[str] = None,
) -> tuple[dict, list[str]]:
- releases = releases or fetch_latest_release
+ releases = releases or fetch_stable_releases
hasher = hasher or hash_asset
result = json.loads(json.dumps(pins))
changes = []
for name in [only] if only else _SECTIONS:
section = result[name]
- moved = updated_section(name, section, releases(section["repo"]), hasher)
- if moved is not None:
+ for release in newer_releases(releases(section["repo"]), section["version"]):
+ try:
+ moved = updated_section(name, section, release, hasher)
+ except AbiTooNew as exc:
+ # stderr: the workflow builds the PR title from stdout.
+ print(f"skipped: {exc}", file = sys.stderr)
+ continue
changes.append(f"{name}: {section['version']} -> {moved['version']}")
result[name] = moved
+ break
return result, changes
diff --git a/studio/frontend/src/features/hub/catalog/npu-catalog-list.tsx b/studio/frontend/src/features/hub/catalog/npu-catalog-list.tsx
index 837ba7f35aa..67a3f3e1a50 100644
--- a/studio/frontend/src/features/hub/catalog/npu-catalog-list.tsx
+++ b/studio/frontend/src/features/hub/catalog/npu-catalog-list.tsx
@@ -6,6 +6,7 @@ import { Spinner } from "@/components/ui/spinner";
import {
type NpuModel,
type NpuPickerSource,
+ NpuRuntimeVersions,
NpuSetupNotice,
npuDownloadLabel,
npuResumeLabel,
@@ -70,6 +71,7 @@ export function NpuCatalogList({
className="mx-auto flex min-h-0 w-full max-w-[var(--hub-measure)] flex-1 flex-col gap-0.5 overflow-y-auto px-3 py-3"
>
{body()}
+ <NpuRuntimeVersions catalog={catalog} className="mt-auto px-3 pt-4" />
</div>
);
}
diff --git a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx
index 79048b069b7..c013d573bf3 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx
+++ b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx
@@ -91,8 +91,10 @@ import type { HfTaskFilter } from "@/features/hub/hooks/use-hub-model-search";
import { INVENTORY_FRESHNESS_WINDOW_MS } from "@/features/hub/inventory";
import { pickNativeModelFolder } from "@/features/native-intents";
import {
+ type NpuCatalog,
type NpuModel,
type NpuPickerSource,
+ NpuRuntimeVersions,
NpuSetupNotice,
npuDownloadLabel,
npuResumeLabel,
@@ -551,6 +553,17 @@ function useRovingModelList({
};
}
+function npuFooterHint(
+ catalog: NpuCatalog,
+ searching: boolean,
+ matches: number,
+): string {
+ if (!catalog.ready) return "Set up the AMD NPU";
+ if (searching) return matches === 1 ? "1 match" : `${matches} matches`;
+ const count = catalog.models?.length;
+ return count ? `${count} available` : "";
+}
+
function ListLabel({
children,
icon,
@@ -4632,7 +4645,6 @@ export function HubModelPicker({
offeredFormatFilters,
);
const [npuOnDeviceCollapsed, setNpuOnDeviceCollapsed] = useState(false);
- const [npuBrowseCollapsed, setNpuBrowseCollapsed] = useState(true);
// Chat passes no task filter and keeps the full set.
const capabilityScope = useMemo<readonly (keyof ModelCapabilities)[] | null>(() => {
const tasks: readonly string[] = task
@@ -7773,13 +7785,26 @@ export function HubModelPicker({
);
};
- const npuBrowseForcedOpen = formatFilter === "npu" || showHfSection;
- const npuBrowseFolded = !npuBrowseForcedOpen && npuBrowseCollapsed;
+ // GPU models own the list; the NPU group shows only under the NPU filter, reached from the footer.
const showNpuBrowse =
npuCatalog !== null &&
- npuListed &&
+ formatFilter === "npu" &&
section === "recommended" &&
- (!showHfSection || npuBrowseRows.length > 0);
+ (!showHfSection || !npuCatalog.ready || npuBrowseRows.length > 0);
+ const showNpuFooter =
+ npuCatalog !== null && formatFilter === "all" && section === "recommended";
+ const ejectButton = onEject ? (
+ <button
+ type="button"
+ data-glass-float=""
+ onClick={() => (ejectsAll ? onEjectAll?.() : onEject())}
+ className="pointer-events-auto inline-flex items-center justify-center gap-2 rounded-full bg-popover px-3 py-2 text-ui-13 font-medium text-destructive shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] transition-colors hover:bg-[color-mix(in_srgb,var(--foreground)_8%,var(--popover))] dark:bg-sidebar-accent dark:shadow-none dark:hover:bg-[color-mix(in_srgb,var(--foreground)_8%,var(--sidebar-accent))]"
+ title={ejectsAll ? "Eject all models" : "Eject model"}
+ >
+ <HugeiconsIcon icon={RemoveCircleIcon} className="size-3.5" />
+ {ejectsAll ? "Eject all" : "Eject model"}
+ </button>
+ ) : null;
return (
<PickerScopes
@@ -8538,34 +8563,20 @@ export function HubModelPicker({
{showNpuBrowse && npuCatalog ? (
<>
- <ListLabel
- collapsed={npuBrowseFolded}
- onToggle={
- npuBrowseForcedOpen
- ? undefined
- : () => setNpuBrowseCollapsed((v) => !v)
- }
- >
- NPU
- </ListLabel>
- {npuBrowseFolded ? null : (
- <>
- {showHfSection ? null : (
- <NpuSetupNotice catalog={npuCatalog} />
- )}
- {npuBrowseRows.map((model) =>
- renderNpuRow(model, false),
- )}
- </>
+ <ListLabel>NPU</ListLabel>
+ {showHfSection && npuCatalog.ready ? null : (
+ <NpuSetupNotice catalog={npuCatalog} />
)}
+ {npuBrowseRows.map((model) => renderNpuRow(model, false))}
+ <NpuRuntimeVersions
+ catalog={npuCatalog}
+ className="px-2.5 pb-1 pt-1.5"
+ />
</>
) : null}
{showRecommendedSection && formatFilter !== "npu" ? (
<>
- {showNpuBrowse ? (
- <ListLabel divider={!npuBrowseFolded}>Unsloth</ListLabel>
- ) : null}
{/* Catalog rows already listed below stand in for a pending or failed Hub list. */}
{recommendedRows.length + moreRows.length === 0 &&
recommendedEmpty === "loading" ? (
@@ -8990,19 +9001,38 @@ export function HubModelPicker({
)}
</div>
</div>
- {onEject ? (
- <div className="pointer-events-none absolute inset-x-0 bottom-0 flex justify-end pr-3.5 pb-[calc(19px*var(--ui-space-scale,1))]">
+ {showNpuFooter && npuCatalog ? (
+ <div className="relative">
+ {/* Over the list's bottom as without a footer: 19px less this footer's 8px spacing. */}
+ {ejectButton ? (
+ <div className="pointer-events-none absolute inset-x-0 bottom-full flex justify-end pr-3.5 pb-[calc(11px*var(--ui-space-scale,1))]">
+ {ejectButton}
+ </div>
+ ) : null}
<button
type="button"
- data-glass-float=""
- onClick={() => (ejectsAll ? onEjectAll?.() : onEject())}
- className="pointer-events-auto inline-flex items-center justify-center gap-2 rounded-full bg-popover px-3 py-2 text-ui-13 font-medium text-destructive shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)] transition-colors hover:bg-[color-mix(in_srgb,var(--foreground)_8%,var(--popover))] dark:bg-sidebar-accent dark:shadow-none dark:hover:bg-[color-mix(in_srgb,var(--foreground)_8%,var(--sidebar-accent))]"
- title={ejectsAll ? "Eject all models" : "Eject model"}
+ data-testid="picker-npu-footer"
+ onClick={() => setFormatFilter("npu")}
+ className="flex w-full items-center gap-2 border-t border-border/60 px-3 pt-2 pb-1.5 text-left text-ui-12 text-muted-foreground transition-colors hover:text-foreground"
>
- <HugeiconsIcon icon={RemoveCircleIcon} className="size-3.5" />
- {ejectsAll ? "Eject all" : "Eject model"}
+ <span
+ aria-hidden={true}
+ className="size-1.5 shrink-0 rounded-full bg-format-npu"
+ />
+ <span className="font-medium text-foreground">NPU models</span>
+ <span className="min-w-0 truncate">
+ {npuFooterHint(npuCatalog, showHfSection, npuBrowseRows.length)}
+ </span>
+ <HugeiconsIcon
+ icon={ChevronRightStandardIcon}
+ className="ml-auto size-3 shrink-0"
+ />
</button>
</div>
+ ) : ejectButton ? (
+ <div className="pointer-events-none absolute inset-x-0 bottom-0 flex justify-end pr-3.5 pb-[calc(19px*var(--ui-space-scale,1))]">
+ {ejectButton}
+ </div>
) : null}
</div>
<TransportConflictDialog
diff --git a/studio/frontend/src/features/npu/api.ts b/studio/frontend/src/features/npu/api.ts
index 019273e54e7..66e1b92dc6a 100644
--- a/studio/frontend/src/features/npu/api.ts
+++ b/studio/frontend/src/features/npu/api.ts
@@ -79,6 +79,20 @@ export function npuRowsFor(
);
}
+/** "FastFlowLM v1.0.12 · Lemonade v2026.44.1", or null when no version is known. */
+export function npuRuntimeLabel(
+ versions: NpuStatus["versions"],
+): string | null {
+ const parts: string[] = [];
+ for (const [name, version] of [
+ ["FastFlowLM", versions?.fastflowlm],
+ ["Lemonade", versions?.lemonade],
+ ] as const) {
+ if (version) parts.push(`${name} v${version.replace(/^v/, "")}`);
+ }
+ return parts.length > 0 ? parts.join(" · ") : null;
+}
+
export function npuSizeLabel(sizeGb: number | null): string | null {
if (sizeGb == null) return null;
return sizeGb < 1
diff --git a/studio/frontend/src/features/npu/index.ts b/studio/frontend/src/features/npu/index.ts
index f298794e5a1..d1b7d309dcf 100644
--- a/studio/frontend/src/features/npu/index.ts
+++ b/studio/frontend/src/features/npu/index.ts
@@ -12,7 +12,7 @@ export {
npuRowsFor,
npuSizeLabel,
} from "./api";
-export { NpuSetupNotice } from "./npu-setup-notice";
+export { NpuRuntimeVersions, NpuSetupNotice } from "./npu-setup-notice";
export {
type NpuCatalog,
type NpuPickerSource,
diff --git a/studio/frontend/src/features/npu/npu-setup-notice.tsx b/studio/frontend/src/features/npu/npu-setup-notice.tsx
index 2d856695abc..e306b493beb 100644
--- a/studio/frontend/src/features/npu/npu-setup-notice.tsx
+++ b/studio/frontend/src/features/npu/npu-setup-notice.tsx
@@ -3,10 +3,31 @@
import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";
+import { cn } from "@/lib/utils";
import { Alert02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
+import { npuRuntimeLabel } from "./api";
import type { NpuCatalog } from "./use-npu-catalog";
+export function NpuRuntimeVersions({
+ catalog,
+ className,
+}: {
+ catalog: NpuCatalog;
+ className?: string;
+}) {
+ const label = catalog.ready ? npuRuntimeLabel(catalog.status.versions) : null;
+ if (!label) return null;
+ return (
+ <p
+ data-testid="npu-runtime-versions"
+ className={cn("text-ui-11 text-muted-foreground/70", className)}
+ >
+ {label}
+ </p>
+ );
+}
+
export function NpuSetupNotice({ catalog }: { catalog: NpuCatalog }) {
const { status, ready, models, listError } = catalog;
const problems = status.validation?.problems ?? [];
diff --git a/studio/frontend/tests/npu-api.test.ts b/studio/frontend/tests/npu-api.test.ts
index 69055f47b7a..9d9e4b3ed0f 100644
--- a/studio/frontend/tests/npu-api.test.ts
+++ b/studio/frontend/tests/npu-api.test.ts
@@ -47,6 +47,20 @@ test("recognizes NPU model paths only", () => {
assert.equal(api.isNpuModelId(null), false);
});
+test("npuRuntimeLabel names the installed FastFlowLM and Lemonade versions", () => {
+ const { api } = client(() => Response.json({}));
+ assert.equal(
+ api.npuRuntimeLabel({ fastflowlm: "1.0.12", lemonade: "2026.44.1" }),
+ "FastFlowLM v1.0.12 · Lemonade v2026.44.1",
+ );
+ assert.equal(
+ api.npuRuntimeLabel({ fastflowlm: "v1.0.12", lemonade: null }),
+ "FastFlowLM v1.0.12",
+ );
+ assert.equal(api.npuRuntimeLabel({ fastflowlm: null, lemonade: null }), null);
+ assert.equal(api.npuRuntimeLabel(undefined), null);
+});
+
test("download reports progress across split frames and resolves on complete", async () => {
const c = client(() =>
sse([
diff --git a/studio/frontend/tests/npu-run-settings.test.ts b/studio/frontend/tests/npu-run-settings.test.ts
index 1f640bfcf60..3159f3724e2 100644
--- a/studio/frontend/tests/npu-run-settings.test.ts
+++ b/studio/frontend/tests/npu-run-settings.test.ts
@@ -17,7 +17,7 @@ const npuLoad = runtime.slice(
const pickers = source("features/model-picker/components/model-selector/pickers.tsx");
const npuRow = pickers.slice(
pickers.indexOf("const renderNpuRow = "),
- pickers.indexOf("const npuBrowseForcedOpen = "),
+ pickers.indexOf("const showNpuBrowse ="),
);
const configPage = source("features/model-picker/components/model-config-page.tsx");
@@ -42,3 +42,9 @@ test("NPU run settings pin customContextLength and offer nothing FastFlowLM igno
assert.match(configPage, /!target\.isGguf && !targetIsMlx && !targetIsNpu && /);
assert.match(configPage, /target\.isGguf \|\| pinsContextLength\s+\? effectiveRuntimeConfig/);
});
+
+test("the NPU footer's setup path keeps the setup notice while a search is active", () => {
+ const browse = pickers.slice(pickers.indexOf("const showNpuBrowse ="));
+ assert.match(browse, /\(!showHfSection \|\| !npuCatalog\.ready \|\| npuBrowseRows\.length > 0\)/);
+ assert.match(browse, /\{showHfSection && npuCatalog\.ready \? null : \(\s*<NpuSetupNotice/);
+});
diff --git a/studio/lemonade_prebuilt_pins.json b/studio/lemonade_prebuilt_pins.json
index 256436674c9..e92a0bb2cea 100644
--- a/studio/lemonade_prebuilt_pins.json
+++ b/studio/lemonade_prebuilt_pins.json
@@ -1,32 +1,32 @@
{
"schema_version": 1,
"lemonade": {
- "version": "2026.43.3",
+ "version": "2026.44.1",
"repo": "lemonade-sdk/lemonade",
"assets": {
"linux-x64": {
- "name": "lemonade-embeddable-2026.43.3-ubuntu-x64.tar.gz",
- "sha256": "d9a2fe01d7fd60ed9ec94822fea814a6d0e8aed46b39be8f126de74ba242b023",
- "size": 7341867
+ "name": "lemonade-embeddable-2026.44.1-ubuntu-x64.tar.gz",
+ "sha256": "16f156a7f44a32b20936e76019b24dbccc7b82e60a3acea12e8614da8bca8e90",
+ "size": 7395871
},
"windows-x64": {
- "name": "lemonade-embeddable-2026.43.3-windows-x64.zip",
- "sha256": "665c697182f775e0a4a22b40d012e145591b67adec910bc38db59859982fc5a7",
- "size": 5440848
+ "name": "lemonade-embeddable-2026.44.1-windows-x64.zip",
+ "sha256": "7ff6c5d6ab612c33690411a7e53d6d0dd62eb515a073375c35015b0778a5a344",
+ "size": 5487764
}
}
},
"fastflowlm": {
- "version": "v1.0.10",
+ "version": "v1.0.12",
"repo": "ROCm/FastFlowLM",
"assets": {
"linux-x64": {
- "name": "fastflowlm_1.0.10_linux.tar.gz",
- "sha256": "af583a1dc449a82a0961c9aabd34cf5548a4e0b0751f016a077204a281bcb77a"
+ "name": "fastflowlm_1.0.12_linux.tar.gz",
+ "sha256": "626fbee5e5206a215a8c2c4d3d961055cbf7289d257d36599e9fef38f2f555a8"
},
"windows-x64": {
- "name": "fastflowlm_1.0.10_windows_amd64.zip",
- "sha256": "a7063890d7b91037a07f381a396a0d7787ebdb69e1b03280971faf0a80f35b73"
+ "name": "fastflowlm_1.0.12_windows_amd64.zip",
+ "sha256": "568706c537398d597f3f24b5094fc58e65126c56f118971f2910c26a86ae027c"
}
}
}
diff --git a/tests/studio/install/test_update_lemonade_pins.py b/tests/studio/install/test_update_lemonade_pins.py
index ae2cc4475a8..d42f4d6f4dc 100644
--- a/tests/studio/install/test_update_lemonade_pins.py
+++ b/tests/studio/install/test_update_lemonade_pins.py
@@ -6,8 +6,10 @@
from __future__ import annotations
import hashlib
+import io
import json
import sys
+import tarfile
from pathlib import Path
import pytest
@@ -41,9 +43,9 @@ def _release(tag: str, names: dict[str, str], **overrides) -> dict:
return {"tag_name": tag, "assets": assets}
-def _hasher(url: str) -> tuple[str, int]:
+def _hasher(url: str, needs = None) -> tuple:
data = _blob(url.rsplit("/", 1)[1])
- return hashlib.sha256(data).hexdigest(), len(data)
+ return hashlib.sha256(data).hexdigest(), len(data), needs
def _newer(version: str) -> str:
@@ -65,7 +67,7 @@ def _releases(lemonade: str, flm: str, **overrides):
),
"ROCm/FastFlowLM": _release(flm, up._fastflowlm_assets(flm.lstrip("v")), **overrides),
}
- return lambda repo: by_repo[repo]
+ return lambda repo: [by_repo[repo]]
def test_newer_releases_move_both_pins_in_the_installers_format():
@@ -125,8 +127,8 @@ def test_an_asset_without_a_published_digest_is_refused():
def test_a_release_missing_an_asset_is_refused():
release = _release(NEW_FLM, {"linux-x64": f"fastflowlm_{NEW_FLM[1:]}_linux.tar.gz"})
- releases = {"lemonade-sdk/lemonade": {"tag_name": "v1.0.0", "assets": []}}
- releases["ROCm/FastFlowLM"] = release
+ releases = {"lemonade-sdk/lemonade": [{"tag_name": "v1.0.0", "assets": []}]}
+ releases["ROCm/FastFlowLM"] = [release]
with pytest.raises(RuntimeError, match = "windows_amd64.zip"):
up.update_pins(lp.load_pins(), releases.__getitem__, _hasher)
@@ -134,7 +136,7 @@ def test_a_release_missing_an_asset_is_refused():
def test_write_is_idempotent_and_only_limits_the_sections(tmp_path, monkeypatch):
path = tmp_path / "pins.json"
path.write_text(json.dumps(lp.load_pins(), indent = 2) + "\n", encoding = "utf-8")
- monkeypatch.setattr(up, "fetch_latest_release", _releases(NEW_LEMONADE, NEW_FLM))
+ monkeypatch.setattr(up, "fetch_stable_releases", _releases(NEW_LEMONADE, NEW_FLM))
monkeypatch.setattr(up, "hash_asset", _hasher)
assert up.main(["--pins", str(path), "--check"]) == 1
assert up.main(["--pins", str(path), "--write", "--only", "fastflowlm"]) == 0
@@ -145,3 +147,122 @@ def test_write_is_idempotent_and_only_limits_the_sections(tmp_path, monkeypatch)
before = path.read_text(encoding = "utf-8")
assert up.main(["--pins", str(path), "--write", "--only", "fastflowlm"]) == 0
assert path.read_text(encoding = "utf-8") == before
+
+
+def _lemonade_only(*tags: str):
+ releases = [_release(tag, up._lemonade_assets(tag.lstrip("v"))) for tag in tags]
+ return lambda repo: releases if repo == "lemonade-sdk/lemonade" else []
+
+
+def _needs_by_version(needs: dict[str, dict]):
+ def hasher(url: str) -> tuple:
+ name = url.rsplit("/", 1)[1]
+ return _hasher(url, next((n for v, n in needs.items() if f"-{v}-ubuntu" in name), None))
+
+ return hasher
+
+
+def test_a_release_needing_a_newer_glibc_falls_back_to_the_newest_that_runs(capsys):
+ pins = lp.load_pins()
+ major = up.version_key(pins["lemonade"]["version"])[0]
+ broken, good, older = f"{major + 2}.0.1", f"{major + 1}.0.2", f"{major + 1}.0.1"
+ hasher = _needs_by_version(
+ {broken: {"GLIBC": (2, 43)}, good: {"GLIBC": (2, 38)}, older: {"GLIBC": (2, 35)}}
+ )
+ releases = _lemonade_only(f"v{older}", f"v{broken}", f"v{good}")
+ new, changes = up.update_pins(pins, releases, hasher, only = "lemonade")
+ assert changes == [f"lemonade: {pins['lemonade']['version']} -> {good}"]
+ assert new["lemonade"]["version"] == good
+ assert "needs GLIBC 2.43 > 2.39." in capsys.readouterr().err
+
+
+def test_only_releases_needing_a_newer_glibc_change_nothing():
+ pins = lp.load_pins()
+ broken = _newer(pins["lemonade"]["version"])
+ hasher = _needs_by_version({broken[1:]: {"GLIBC": (2, 40)}})
+ assert up.update_pins(pins, _lemonade_only(broken), hasher, only = "lemonade") == (pins, [])
+
+
+def test_the_abi_limits_themselves_are_accepted():
+ pins = lp.load_pins()
+ tag = _newer(pins["lemonade"]["version"])
+ hasher = _needs_by_version({tag[1:]: dict(up.LINUX_ABI_LIMITS)})
+ _, changes = up.update_pins(pins, _lemonade_only(tag), hasher, only = "lemonade")
+ assert changes == [f"lemonade: {pins['lemonade']['version']} -> {tag[1:]}"]
+
+
+def test_candidate_tags_are_not_releases():
+ pins = lp.load_pins()
+ newer = _newer(pins["lemonade"]["version"])
+ assert (
+ up.newer_releases([{"tag_name": "candidate-" + newer}], pins["lemonade"]["version"]) == []
+ )
+
+
+def test_stable_releases_are_read_from_every_page(monkeypatch):
+ first = f"{up._API}/repos/lemonade-sdk/lemonade/releases?per_page=100"
+ second = f"{up._API}/repositories/1/releases?per_page=100&page=2"
+ pages = {
+ first: (
+ [{"tag_name": f"candidate-v9.{n}.0", "prerelease": True} for n in range(100)],
+ f'<{second}>; rel="next", <{second}>; rel="last"',
+ ),
+ second: ([{"tag_name": "v9.0.1"}, {"tag_name": "v9.0.0", "draft": True}], None),
+ }
+
+ class Page(io.BytesIO):
+ def __init__(self, url):
+ body, link = pages[url]
+ super().__init__(json.dumps(body).encode())
+ self.headers = {"Link": link} if link else {}
+
+ seen = []
+ monkeypatch.setattr(
+ up.urllib.request,
+ "urlopen",
+ lambda request, timeout: seen.append(request.full_url) or Page(request.full_url),
+ )
+ assert up.fetch_stable_releases("lemonade-sdk/lemonade") == [{"tag_name": "v9.0.1"}]
+ assert seen == [first, second]
+
+
+def _tarball(files: dict[str, bytes]) -> io.BytesIO:
+ buffer = io.BytesIO()
+ with tarfile.open(fileobj = buffer, mode = "w:gz") as archive:
+ for name, data in files.items():
+ info = tarfile.TarInfo(name)
+ info.size = len(data)
+ archive.addfile(info, io.BytesIO(data))
+ buffer.seek(0)
+ return buffer
+
+
+def test_abi_needs_read_only_elf_files():
+ elf = b"\x7fELF" + b"\0" * 60 + b"GLIBC_2.2.5\0GLIBC_2.38\0GLIBCXX_3.4.32\0OPENSSL_3.0.0\0"
+ lib = b"\x7fELF" + b"\0" * 60 + b"GLIBC_2.43\0OPENSSL_3.2.0\0"
+ script = b"#!/bin/sh\n# needs GLIBC_2.99\n"
+ expected = {"GLIBC": (2, 38), "GLIBCXX": (3, 4, 32), "OPENSSL": (3, 0, 0)}
+ assert up.tar_abi_needs(_tarball({"x/lemond": elf, "x/flm": script})) == expected
+ both = up.tar_abi_needs(_tarball({"x/lemond": elf, "x/lib/libfoo.so": lib}))
+ assert both == {**expected, "GLIBC": (2, 43), "OPENSSL": (3, 2, 0)}
+ assert up.tar_abi_needs(_tarball({"x/README": b"GLIBC_2.50"})) == {}
+
+
+def test_a_newer_openssl_alone_is_skipped(capsys):
+ pins = lp.load_pins()
+ tag = _newer(pins["lemonade"]["version"])
+ hasher = _needs_by_version({tag[1:]: {"GLIBC": (2, 38), "OPENSSL": (3, 2, 0)}})
+ assert up.update_pins(pins, _lemonade_only(tag), hasher, only = "lemonade") == (pins, [])
+ assert "needs OPENSSL 3.2.0 > 3.0.9." in capsys.readouterr().err
+
+
+def test_a_digest_mismatch_is_refused_even_when_glibc_would_skip_it():
+ pins = lp.load_pins()
+ tag = _newer(pins["lemonade"]["version"])
+ name = f"lemonade-embeddable-{tag[1:]}-ubuntu-x64.tar.gz"
+ release = _release(
+ tag, up._lemonade_assets(tag[1:]), **{name: {"digest": "sha256:" + "0" * 64}}
+ )
+ hasher = _needs_by_version({tag[1:]: {"GLIBC": (2, 43)}})
+ with pytest.raises(RuntimeError, match = "GitHub publishes"):
+ up.update_pins(pins, lambda repo: [release], hasher, only = "lemonade")