Skip to content

Commit

Permalink
fix: Type correction on renaming file api (#488)
Browse files Browse the repository at this point in the history
* fix: Set default value for `is_dir` param in renaming file function
* fix: Add exception handling on storage related request on manager component
  • Loading branch information
lizable committed Jun 23, 2022
1 parent 43bc1d1 commit ae1c3c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/488.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add default value for `is_dir` parameter at rename_file function described in storage-proxy API
8 changes: 5 additions & 3 deletions src/ai/backend/manager/models/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .base import (
Item, PaginatedList,
)
from ..api.exceptions import VFolderOperationFailed
from ..api.exceptions import InvalidAPIParameters, VFolderOperationFailed
from ..exceptions import InvalidArgument
if TYPE_CHECKING:
from .gql import GraphQueryContext
Expand Down Expand Up @@ -144,7 +144,6 @@ async def request(
vfolder_host_or_proxy_name: str,
method: str,
request_relpath: str,
/,
*args,
**kwargs,
) -> AsyncIterator[Tuple[yarl.URL, aiohttp.ClientResponse]]:
Expand All @@ -165,15 +164,18 @@ async def request(
try:
error_data = await client_resp.json()
raise VFolderOperationFailed(
extra_msg=error_data.pop("msg"),
extra_msg=error_data.pop("msg", None),
extra_data=error_data,
)
except aiohttp.ClientResponseError:
# when the response body is not JSON, just raise with status info.
raise VFolderOperationFailed(
extra_msg=f"Storage proxy responded with "
f"{client_resp.status} {client_resp.reason}",
extra_data=None,
)
except VFolderOperationFailed as e:
raise InvalidAPIParameters(e.extra_msg, e.extra_data)
yield proxy_info.client_api_url, client_resp


Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/storage/api/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ async def rename_file(request: web.Request) -> web.Response:
t.Key("vfid"): tx.UUID(),
t.Key("relpath"): tx.PurePath(relative_only=True),
t.Key("new_name"): t.String(),
t.Key("is_dir"): t.ToBool(), # ignored since 22.03
t.Key("is_dir", default=False): t.ToBool, # ignored since 22.03
},
),
) as params:
Expand Down

0 comments on commit ae1c3c6

Please sign in to comment.