Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions omlx/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3052,7 +3052,7 @@ async def delete_hf_model(
except ValueError:
raise HTTPException(status_code=400, detail="Invalid model name")

if not model_path.is_dir():
if not model_path.is_dir() and not model_path.is_symlink():
raise HTTPException(status_code=400, detail="Not a model directory")

# Unload model if loaded
Expand Down Expand Up @@ -3082,11 +3082,15 @@ def _handle_onerror(func, path, exc_info):
raise exc_info[1].with_traceback(exc_info[2])

try:
if sys.version_info >= (3, 12):
if model_path.is_symlink():
model_path.unlink()
logger.info(f"Deleted model symlink: {model_path}")
elif sys.version_info >= (3, 12):
shutil.rmtree(model_path, onexc=_handle_onexc)
logger.info(f"Deleted model directory: {model_path}")
else:
shutil.rmtree(model_path, onerror=_handle_onerror)
logger.info(f"Deleted model directory: {model_path}")
logger.info(f"Deleted model directory: {model_path}")
except Exception as e:
logger.error(f"Failed to delete model directory {model_path}: {e}")
raise HTTPException(status_code=500, detail=f"Failed to delete model: {e}")
Expand Down