Download progress#41
Open
thisismugil wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
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_classhook 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.
| "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 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 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(",") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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