Skip to content

Commit

Permalink
feature: now check handling error and fixed docs accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
mirageoasis committed Dec 23, 2023
1 parent 9c3a5fe commit 16d2d07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changes/1803.feature.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add support for multi directory mkdir and fix type annotation accordingly
Add support for multi directory mkdir by fixing cli to accept multiple arguments and by adding list type annotation to accept multiple directories
15 changes: 14 additions & 1 deletion src/ai/backend/storage/api/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,20 @@ class Params(TypedDict):
volume.mkdir(vfid, rpath, parents=parents, exist_ok=exist_ok)
for rpath in relpaths
]
await asyncio.gather(*mkdir_tasks)
result_group = await asyncio.gather(*mkdir_tasks, return_exceptions=True)

# if result group is all false throw error.
if all([isinstance(res, FileExistsError) for res in result_group]):
raise FileExistsError("None of directories created because they already exist")

for result_or_exception in result_group:
if isinstance(result_or_exception, BaseException):
log.error(
"%s",
repr(result_or_exception),
exc_info=result_or_exception,
)

return web.Response(status=204)


Expand Down

0 comments on commit 16d2d07

Please sign in to comment.