Skip to content

Download progress#41

Open
thisismugil wants to merge 3 commits into
devfrom
download-progress
Open

Download progress#41
thisismugil wants to merge 3 commits into
devfrom
download-progress

Conversation

@thisismugil

Copy link
Copy Markdown
Collaborator

Download Progress optimization. To match both Webui and Local Terminal.
Pause, terminate, Resume of download.

Checkout the code and working of the feature and then merge with dev

Copilot AI review requested due to automatic review settings June 24, 2026 10:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the model download experience by adding pause/resume/cancel controls and improving real-time progress streaming so Web UI progress aligns with terminal progress reporting.

Changes:

  • Added server-side pause/resume/cancel download endpoints and download manager support for paused/cancelled states.
  • Refactored Web UI to centralize SSE download progress streaming in a download context and to persist/restore ongoing/paused downloads.
  • Reworked Hugging Face download progress reporting to use an official tqdm_class hook so callback bytes match the terminal progress bar.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
pyproject.toml Adds Pillow dependency used for image/vision features.
oprel/webui-react/services/downloadContext.tsx Centralizes download state + SSE streaming; adds pause/resume/cancel wiring.
oprel/webui-react/services/api.ts Adds pause/resume/cancel API calls and updates SSE streaming behavior.
oprel/webui-react/components/ModelsView.tsx Refreshes local quantizations when download status changes to update LOCAL badges.
oprel/server/services/downloads.py Adds encoded download IDs, streaming keepalive, and pause/resume/cancel service functions.
oprel/server/routes/downloads.py Exposes new pause/resume/cancel routes.
oprel/server/download_manager.py Fixes speed calculation and adds paused/cancelled status setters.
oprel/downloader/hub.py Implements progress callbacks using hf_hub_download(tqdm_class=...) for accurate bytes.
oprel/core/exceptions.py Introduces download pause/cancel exceptions used by the downloader worker.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
"python-docx>=1.1.2",
"google-genai>=2.0.0",
"groq>=0.9.0",
"Pillow>=10.0.0",
Comment on lines +43 to +51
let refreshModelsGlobal: () => Promise<void> = async () => {};
try {
const app = useApp();
if (app) {
refreshModelsGlobal = app.refreshModels;
}
} catch (e) {
console.warn("DownloadProvider: AppContext not available");
}
title: "Download Complete",
description: `${modelName} (${quantization}) is ready to use`,
})
refreshModelsGlobal();
total: progress.total,
speed: progress.speed,
timeLeft: formatTime(progress.eta),
status: "ongoing",
Comment on lines +212 to +224
const pauseDownload = useCallback(async (modelId: string) => {
setDownloads((prev) => {
const download = prev.find((d) => d.modelId === modelId)
if (download && download.downloadId) {
API.pauseDownload(download.downloadId).catch(console.error)
}
if (activeStreams.current[modelId]) {
activeStreams.current[modelId]()
delete activeStreams.current[modelId]
}
return prev.map((d) => (d.modelId === modelId ? { ...d, status: "paused" as const, speed: 0 } : d))
})
}, [])
Comment on lines 133 to 137
quant = quantization or "Q8_0"
raw_id = f"{resolved}:GGUF:{uuid.uuid4().hex[:8]}"
download_id = base64.urlsafe_b64encode(raw_id.encode()).decode().rstrip("=")
download_id = _encode_download_id(raw_id)

download_manager.start_download(raw_id, resolved, "GGUF")
Comment on lines +68 to +71
prev_bytes = getattr(download, '_last_bytes', downloaded_bytes)
bytes_diff = downloaded_bytes - prev_bytes
if bytes_diff >= 0:
download.speed_bps = bytes_diff / time_diff
Comment thread oprel/downloader/hub.py
Comment on lines +772 to +778
model_path = _hf_hub_download(
repo_id=model_id,
filename=filename,
cache_dir=str(cache_dir),
force_download=force_download,
tqdm_class=tqdm_class_to_use,
)
Comment thread oprel/downloader/hub.py
Comment on lines +742 to +746
class _ProgressTqdm(_hf_tqdm):
"""
Official tqdm_class replacement for hf_hub_download.

hf_hub_download creates this instance via _get_progress_bar_context
}

// Fetch local quantizations when model changes
const downloadsKey = downloads.map((d) => `${d.modelId}-${d.status}`).join(",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants