mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-03-15 00:07:28 +00:00
Downloader: log errors when downloading
If an error is returned from HuggingFace, raise it to the calling function. Signed-off-by: kingbri <8082010+kingbri1@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import traceback
|
||||
from loguru import logger
|
||||
|
||||
from common.downloader import hf_repo_download
|
||||
@@ -10,16 +11,20 @@ from endpoints.server import export_openapi
|
||||
|
||||
|
||||
def download_action(args: argparse.Namespace):
|
||||
asyncio.run(
|
||||
hf_repo_download(
|
||||
repo_id=args.repo_id,
|
||||
folder_name=args.folder_name,
|
||||
revision=args.revision,
|
||||
token=args.token,
|
||||
include=args.include,
|
||||
exclude=args.exclude,
|
||||
try:
|
||||
asyncio.run(
|
||||
hf_repo_download(
|
||||
repo_id=args.repo_id,
|
||||
folder_name=args.folder_name,
|
||||
revision=args.revision,
|
||||
token=args.token,
|
||||
include=args.include,
|
||||
exclude=args.exclude,
|
||||
)
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
exception = traceback.format_exc()
|
||||
logger.error(exception)
|
||||
|
||||
|
||||
def config_export_action(args: argparse.Namespace):
|
||||
|
||||
@@ -37,8 +37,14 @@ async def _download_file(
|
||||
req_headers = {"Authorization": f"Bearer {token}"} if token else {}
|
||||
|
||||
async with session.get(url, headers=req_headers) as response:
|
||||
# TODO: Change to raise errors
|
||||
assert response.status == 200
|
||||
if not response.ok:
|
||||
error_text = await response.text()
|
||||
raise aiohttp.ClientResponseError(
|
||||
response.request_info,
|
||||
response.history,
|
||||
status=response.status,
|
||||
message=f"HTTP {response.status}: {error_text}",
|
||||
)
|
||||
|
||||
file_size = int(response.headers["Content-Length"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user