Release / release (push) Successful in 12m32s
Kaname keeps two jobs: the model downloader and benchmarks. Benchmarks now run against endpoints (any OpenAI-compatible server added by URL, with an optional server-side API key and hand-written hardware notes) instead of deployments Kaname started itself. Removed: runtimes, deployments, sweeps, resource telemetry, hardware detection, the /api/v1 API with tokens and guardrails, and all Docker access. The quality eval's coding tests run in a network-less sandbox container that shares only an exchange folder with the worker. The previous state is kept in branch backup / tag backup-0.14.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
170 lines
6.8 KiB
TypeScript
170 lines
6.8 KiB
TypeScript
"use client";
|
|
|
|
import { DownloadIcon, ShieldCheckIcon, WrenchIcon } from "lucide-react";
|
|
import Link from "next/link";
|
|
import { useState } from "react";
|
|
import { cancelJob, startDownload, startRepair, startVerify } from "@/components/job-actions";
|
|
import { JobProgress, JobStateBadge } from "@/components/job-progress";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Progress } from "@/components/ui/progress";
|
|
import { VerifyResult } from "@/components/verify-result";
|
|
import { useLive } from "@/hooks/use-live";
|
|
import type { ModelStatus } from "@/lib/db/schema";
|
|
import { groupJobFiles } from "@/lib/file-groups";
|
|
import { formatBytes, percent } from "@/lib/format";
|
|
import { jobLabel } from "@/lib/job-labels";
|
|
|
|
const OPEN = ["queued", "downloading", "verifying"];
|
|
const VERIFY_KINDS = ["verify", "deep_verify"];
|
|
|
|
/** Sidebar card: current job with progress, the last verify result, and the model's actions. */
|
|
export function DownloadCard({
|
|
modelId,
|
|
status,
|
|
hubMissing,
|
|
}: {
|
|
modelId: string;
|
|
status: ModelStatus;
|
|
/** The repo or pinned commit is gone from the Hub; no new downloads. */
|
|
hubMissing: boolean;
|
|
}) {
|
|
const { snapshot } = useLive({ model: modelId });
|
|
const [busy, setBusy] = useState(false);
|
|
const jobs = snapshot?.jobs ?? [];
|
|
const latest = jobs[0];
|
|
const open = latest && OPEN.includes(latest.state) ? latest : undefined;
|
|
const files = open ? groupJobFiles(snapshot?.files ?? []) : [];
|
|
// The newest verify, unless a download ran after it (its result would be stale).
|
|
const lastCheck = jobs.find((j) => VERIFY_KINDS.includes(j.kind) || j.kind === "download");
|
|
const verify = lastCheck && VERIFY_KINDS.includes(lastCheck.kind) && lastCheck.state === "completed" ? lastCheck : undefined;
|
|
const verifyProblems = verify?.result
|
|
? (verify.result.missing?.length ?? 0) + (verify.result.sizeMismatch?.length ?? 0) + (verify.result.hashMismatch?.length ?? 0)
|
|
: 0;
|
|
|
|
async function run(fn: () => Promise<unknown>) {
|
|
setBusy(true);
|
|
try {
|
|
await fn();
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
const neverRan = jobs.length === 0;
|
|
const downloadLabel = neverRan
|
|
? "Download"
|
|
: latest?.state === "interrupted" || latest?.state === "cancelled"
|
|
? "Resume"
|
|
: latest?.state === "failed" && latest.kind === "download"
|
|
? "Retry"
|
|
: "Download missing";
|
|
const canDownload = !open && !hubMissing && status !== "ready" && status !== "deleting" && !!snapshot;
|
|
const canVerify = !open && !neverRan && status !== "deleting" && !!snapshot;
|
|
const needsRepair = !open && !hubMissing && status !== "deleting" && (verifyProblems > 0 || status === "incomplete");
|
|
|
|
let hint = "Downloads the selected files at the pinned commit.";
|
|
if (open?.state === "queued") hint = snapshot?.worker.online ? "Waiting for a free slot." : "Queued, but the worker is offline.";
|
|
else if (open) hint = "Runs in the background; you can close this page.";
|
|
else if (status === "deleting") hint = "Deleting…";
|
|
else if (hubMissing && status !== "ready") hint = "Can't download: no longer available on Hugging Face. Local files are kept.";
|
|
else if (status === "ready") hint = "All selected files are present.";
|
|
|
|
const showProgress =
|
|
latest && latest.kind !== "delete" && !(latest.state === "completed" && (status === "ready" || VERIFY_KINDS.includes(latest.kind)));
|
|
|
|
return (
|
|
<div className="flex flex-col gap-3">
|
|
<div className="flex items-center justify-between gap-2">
|
|
<h3 className="flex items-center gap-1.5 text-sm font-semibold">
|
|
<DownloadIcon className="size-4 text-muted-foreground" />
|
|
{open ? jobLabel(open) : "Download"}
|
|
</h3>
|
|
{latest && <JobStateBadge job={latest} />}
|
|
</div>
|
|
<p className="text-xs text-muted-foreground">{hint}</p>
|
|
|
|
{showProgress && <JobProgress job={latest} compact />}
|
|
|
|
{latest?.state === "failed" && latest.errorMessage && (
|
|
<pre className="max-h-40 overflow-auto rounded-md bg-destructive/10 px-2.5 py-2 text-xs whitespace-pre-wrap text-destructive">
|
|
{latest.errorMessage}
|
|
</pre>
|
|
)}
|
|
|
|
{files.length > 0 && (
|
|
<ul className="flex flex-col gap-1.5">
|
|
{files.map((f) => (
|
|
<li key={f.path} className="flex flex-col gap-1">
|
|
<div className="flex justify-between gap-2 text-xs">
|
|
<span className="truncate font-mono" title={f.path}>
|
|
{f.path}
|
|
{f.parts > 1 && <span className="text-muted-foreground"> · {f.parts} parts</span>}
|
|
</span>
|
|
<span className="shrink-0 text-muted-foreground tabular-nums">{formatBytes(f.expectedBytes)}</span>
|
|
</div>
|
|
<Progress value={percent(f.doneBytes, f.expectedBytes)} />
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)}
|
|
|
|
{verify?.result && !open && (
|
|
<div className="rounded-md bg-muted/50 px-2.5 py-2">
|
|
<VerifyResult result={verify.result} deep={verify.kind === "deep_verify"} />
|
|
</div>
|
|
)}
|
|
|
|
<div className="flex flex-wrap gap-2">
|
|
{open ? (
|
|
<Button variant="destructive" size="sm" disabled={busy || open.cancelRequested} onClick={() => run(() => cancelJob(open.id))}>
|
|
{open.cancelRequested ? "Cancelling…" : "Cancel"}
|
|
</Button>
|
|
) : (
|
|
<>
|
|
{needsRepair ? (
|
|
<Button size="sm" disabled={busy} onClick={() => run(() => startRepair(modelId))}>
|
|
<WrenchIcon />
|
|
Repair
|
|
</Button>
|
|
) : (
|
|
canDownload && (
|
|
<Button size="sm" disabled={busy} onClick={() => run(() => startDownload(modelId))}>
|
|
{downloadLabel}
|
|
</Button>
|
|
)
|
|
)}
|
|
{canVerify && (
|
|
<>
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
disabled={busy}
|
|
onClick={() => run(() => startVerify(modelId, false))}
|
|
title="Check that every selected file exists with the right size (seconds)"
|
|
>
|
|
<ShieldCheckIcon />
|
|
Verify
|
|
</Button>
|
|
<Button
|
|
size="sm"
|
|
variant="ghost"
|
|
disabled={busy}
|
|
onClick={() => run(() => startVerify(modelId, true))}
|
|
title="Hash every file and compare with the Hub (slow: reads every byte)"
|
|
>
|
|
Deep verify
|
|
</Button>
|
|
</>
|
|
)}
|
|
</>
|
|
)}
|
|
{latest && latest.kind !== "delete" && (
|
|
<Link href={`/jobs/${latest.id}`} className="inline-flex h-7 items-center rounded-md px-2.5 text-[0.8rem] hover:bg-muted">
|
|
View log
|
|
</Link>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|