Skip to content

Commit

Permalink
fix(BA-515): Let the vfolder REST API accept vfolder UUIDs as intended (
Browse files Browse the repository at this point in the history
#3451)

Co-authored-by: octodog <[email protected]>
Co-authored-by: Sanghun Lee <[email protected]>
Co-authored-by: Sion Kang <[email protected]>
  • Loading branch information
4 people authored Jan 17, 2025
1 parent 3ab69eb commit 482da3b
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 279 deletions.
1 change: 1 addition & 0 deletions changes/3451.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a mis-implementation that has prevented using UUIDs to indicate an exact vfolder when invoking the vfolder REST API
27 changes: 24 additions & 3 deletions src/ai/backend/manager/api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from __future__ import annotations

import json
from typing import Any, Dict, Mapping, Optional, Union, cast
from collections.abc import Mapping, Sequence
from typing import TYPE_CHECKING, Any, Optional, Union, cast

from aiohttp import web

Expand All @@ -21,6 +22,9 @@

from ..exceptions import AgentError

if TYPE_CHECKING:
from ai.backend.manager.api.vfolder import VFolderRow


class BackendError(web.HTTPError):
"""
Expand Down Expand Up @@ -247,7 +251,10 @@ class TooManySessionsMatched(BackendError, web.HTTPNotFound):
error_title = "Too many sessions matched."

def __init__(
self, extra_msg: Optional[str] = None, extra_data: Optional[Dict[str, Any]] = None, **kwargs
self,
extra_msg: Optional[str] = None,
extra_data: Optional[dict[str, Any]] = None,
**kwargs,
):
if extra_data is not None and (matches := extra_data.get("matches", None)) is not None:
serializable_matches = [
Expand Down Expand Up @@ -288,7 +295,21 @@ class VFolderCreationFailed(BackendError, web.HTTPBadRequest):

class TooManyVFoldersFound(BackendError, web.HTTPNotFound):
error_type = "https://api.backend.ai/probs/too-many-vfolders"
error_title = "There are two or more matching vfolders."
error_title = "Multiple vfolders found for the operation for a single vfolder."

def __init__(self, matched_rows: Sequence[VFolderRow]) -> None:
serialized_matches = [
{
"id": row["id"],
"host": row["host"],
"user": row["user_email"],
"user_id": row["user"],
"group": row["group_name"],
"group_id": row["group"],
}
for row in matched_rows
]
super().__init__(extra_data={"matches": serialized_matches})


class VFolderNotFound(ObjectNotFound):
Expand Down
Loading

0 comments on commit 482da3b

Please sign in to comment.