Skip to content

Commit

Permalink
Remove internal model download endpoint (#5432)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Nov 28, 2024
1 parent b666539 commit 20879c7
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 605 deletions.
1 change: 0 additions & 1 deletion api_server/routes/internal/internal_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class InternalRoutes:
The top level web router for internal routes: /internal/*
The endpoints here should NOT be depended upon. It is for ComfyUI frontend use only.
Check README.md for more information.
'''

def __init__(self, prompt_server):
Expand Down
2 changes: 0 additions & 2 deletions model_filemanager/__init__.py

This file was deleted.

234 changes: 0 additions & 234 deletions model_filemanager/download_models.py

This file was deleted.

31 changes: 0 additions & 31 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import node_helpers
from app.frontend_management import FrontendManager
from app.user_manager import UserManager
from model_filemanager import download_model, DownloadModelStatus
from typing import Optional
from api_server.routes.internal.internal_routes import InternalRoutes

Expand Down Expand Up @@ -676,36 +675,6 @@ async def post_history(request):
self.prompt_queue.delete_history_item(id_to_delete)

return web.Response(status=200)

# Internal route. Should not be depended upon and is subject to change at any time.
# TODO(robinhuang): Move to internal route table class once we refactor PromptServer to pass around Websocket.
# NOTE: This was an experiment and WILL BE REMOVED
@routes.post("/internal/models/download")
async def download_handler(request):
async def report_progress(filename: str, status: DownloadModelStatus):
payload = status.to_dict()
payload['download_path'] = filename
await self.send_json("download_progress", payload)

data = await request.json()
url = data.get('url')
model_directory = data.get('model_directory')
folder_path = data.get('folder_path')
model_filename = data.get('model_filename')
progress_interval = data.get('progress_interval', 1.0) # In seconds, how often to report download progress.

if not url or not model_directory or not model_filename or not folder_path:
return web.json_response({"status": "error", "message": "Missing URL or folder path or filename"}, status=400)

session = self.client_session
if session is None:
logging.error("Client session is not initialized")
return web.Response(status=500)

task = asyncio.create_task(download_model(lambda url: session.get(url), model_filename, url, model_directory, folder_path, report_progress, progress_interval))
await task

return web.json_response(task.result().to_dict())

async def setup(self):
timeout = aiohttp.ClientTimeout(total=None) # no timeout
Expand Down
Loading

0 comments on commit 20879c7

Please sign in to comment.