|
@@ -17,7 +17,6 @@ from exo.helpers import DEBUG, is_frozen
|
|
|
from exo.download.download_progress import RepoProgressEvent, RepoFileProgressEvent, RepoProgressCallback, RepoFileProgressCallback
|
|
|
from exo.inference.shard import Shard
|
|
|
import aiofiles
|
|
|
-from aiofiles import os as aios
|
|
|
|
|
|
T = TypeVar("T")
|
|
|
|
|
@@ -109,16 +108,20 @@ async def move_models_to_hf(seed_dir: Union[str, Path]):
|
|
|
"""Move model in resources folder of app to .cache/huggingface/hub"""
|
|
|
source_dir = Path(seed_dir)
|
|
|
dest_dir = get_hf_home()/"hub"
|
|
|
- await aios.makedirs(dest_dir, exist_ok=True)
|
|
|
- async for path in source_dir.iterdir():
|
|
|
- if path.is_dir() and path.startswith("models--"):
|
|
|
+ await aios.makedirs(dest_dir, exist_ok=True)
|
|
|
+ for path in source_dir.iterdir():
|
|
|
+ if path.is_dir() and path.name.startswith("models--"):
|
|
|
dest_path = dest_dir / path.name
|
|
|
- if dest_path.exists():
|
|
|
- if DEBUG>=1: print(f"skipping moving {dest_path}. File already exists")
|
|
|
+ if await aios.path.exists(dest_path):
|
|
|
+ print('Skipping moving model to .cache directory')
|
|
|
else:
|
|
|
- await aios.rename(str(path), str(dest_path))
|
|
|
-
|
|
|
-
|
|
|
+ try:
|
|
|
+ await aios.rename(str(path), str(dest_path))
|
|
|
+ except Exception as e:
|
|
|
+ print(f'Error moving model to .cache: {e}')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
async def fetch_file_list(session, repo_id, revision, path=""):
|
|
|
api_url = f"{get_hf_endpoint()}/api/models/{repo_id}/tree/{revision}"
|
|
|
url = f"{api_url}/{path}" if path else api_url
|