Milestone (c): worker and downloads with live progress
- Worker queue with per-model exclusivity and MAX_CONCURRENT_DOWNLOADS, spawns `hf download --revision <sha> --local-dir ... --include <exact paths>` with HF_TOKEN via env only - Progress from bytes on disk (final + .incomplete files matched by etag), per job and per file, with speed and ETA; post-download size/etag check - Job logs (sanitized), cancel, graceful interrupt on shutdown, partial-file cleanup (hf 2.1.1 does not resume partials) - Single-worker DB lease, free-space check - SSE live updates for library, model and job pages - Dockerfile + compose.yaml (web, worker, data/models volumes) - HF_HUB_DISABLE_XET default on for measurable progress Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f7ac60ccf
commit
49440154a2
42 files changed
+2974
-110
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { formatBytes, formatDuration, formatSpeed, percent } from "@/lib/format";
|
||||
import type { JobSnapshot } from "@/lib/jobs";
|
||||
|
||||
const STATE_VARIANT: Record<string, "default" | "secondary" | "destructive" | "outline"> = {
|
||||
queued: "outline",
|
||||
downloading: "secondary",
|
||||
verifying: "secondary",
|
||||
completed: "default",
|
||||
failed: "destructive",
|
||||
cancelled: "outline",
|
||||
interrupted: "destructive",
|
||||
};
|
||||
|
||||
export function JobStateBadge({ job }: { job: Pick<JobSnapshot, "state" | "cancelRequested"> }) {
|
||||
const label = job.cancelRequested && !["cancelled", "completed", "failed"].includes(job.state) ? "cancelling" : job.state;
|
||||
return <Badge variant={STATE_VARIANT[job.state] ?? "outline"}>{label}</Badge>;
|
||||
}
|
||||
|
||||
/** Overall progress line for a job: bar, bytes, %, speed, ETA. */
|
||||
export function JobProgress({ job, compact = false }: { job: JobSnapshot; compact?: boolean }) {
|
||||
const pct = percent(job.doneBytes, job.totalBytes);
|
||||
const running = job.state === "downloading" || job.state === "verifying";
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col gap-1.5">
|
||||
<Progress value={pct} />
|
||||
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground tabular-nums">
|
||||
{!compact && <JobStateBadge job={job} />}
|
||||
<span>
|
||||
{formatBytes(job.doneBytes)} / {formatBytes(job.totalBytes)} · {pct.toFixed(1)}%
|
||||
</span>
|
||||
{running && (
|
||||
<>
|
||||
<span>{formatSpeed(job.speedBps)}</span>
|
||||
<span>ETA {formatDuration(job.etaSeconds)}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user