mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-18 22:30:40 -07:00
Refactor model download handling and improve progress tracking
- Rearranged imports for consistency across components. - Enhanced the ModelManagement component to include detailed logging for download actions and errors. - Updated the ModelProgress component to connect to SSE only when actively downloading, preventing connection exhaustion. - Added a downloading state to the model status to indicate ongoing downloads. - Improved toast notifications for model downloads with completion and error callbacks. - Refactored the useModelDownloadToast hook to support new callbacks for download completion and error handling. - Updated backend model status to reflect downloading state during active downloads.
This commit is contained in:
@@ -1161,6 +1161,10 @@ async def get_model_status():
|
||||
import os
|
||||
|
||||
backend_type = get_backend_type()
|
||||
task_manager = get_task_manager()
|
||||
|
||||
# Get set of currently downloading models
|
||||
active_downloads = {task.model_name for task in task_manager.get_active_downloads()}
|
||||
|
||||
# Try to import scan_cache_dir (might not be available in older versions)
|
||||
try:
|
||||
@@ -1328,10 +1332,18 @@ async def get_model_status():
|
||||
except Exception:
|
||||
loaded = False
|
||||
|
||||
# Check if this model is currently being downloaded
|
||||
is_downloading = config["model_name"] in active_downloads
|
||||
|
||||
# If downloading, don't report as downloaded (partial files exist)
|
||||
if is_downloading:
|
||||
downloaded = False
|
||||
|
||||
statuses.append(models.ModelStatus(
|
||||
model_name=config["model_name"],
|
||||
display_name=config["display_name"],
|
||||
downloaded=downloaded,
|
||||
downloading=is_downloading,
|
||||
size_mb=size_mb,
|
||||
loaded=loaded,
|
||||
))
|
||||
@@ -1342,10 +1354,14 @@ async def get_model_status():
|
||||
except Exception:
|
||||
loaded = False
|
||||
|
||||
# Check if this model is currently being downloaded
|
||||
is_downloading = config["model_name"] in active_downloads
|
||||
|
||||
statuses.append(models.ModelStatus(
|
||||
model_name=config["model_name"],
|
||||
display_name=config["display_name"],
|
||||
downloaded=False, # Assume not downloaded if check failed
|
||||
downloading=is_downloading,
|
||||
size_mb=None,
|
||||
loaded=loaded,
|
||||
))
|
||||
|
||||
@@ -134,6 +134,7 @@ class ModelStatus(BaseModel):
|
||||
model_name: str
|
||||
display_name: str
|
||||
downloaded: bool
|
||||
downloading: bool = False # True if download is in progress
|
||||
size_mb: Optional[float] = None
|
||||
loaded: bool = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user