Skip to content

Commit

Permalink
Merge branch 'refactor/implemet-crud-handlers-for-manager' of https:/…
Browse files Browse the repository at this point in the history
…/github.com/lablup/backend.ai into refactor/implemet-crud-handlers-for-manager
  • Loading branch information
seedspirit committed Feb 4, 2025
2 parents 0bebe9f + 5cf5f3c commit b910b73
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 18 deletions.
32 changes: 16 additions & 16 deletions docs/manager/rest-reference/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@
},
"CompactVFolderInfoModel": {
"properties": {
"status": {
"status_code": {
"default": 200,
"exclusiveMaximum": 600,
"minimum": 100,
"title": "Status",
"title": "Status Code",
"type": "integer"
},
"id": {
Expand Down Expand Up @@ -718,11 +718,11 @@
},
"ServeInfoModel": {
"properties": {
"status": {
"status_code": {
"default": 200,
"exclusiveMaximum": 600,
"minimum": 100,
"title": "Status",
"title": "Status Code",
"type": "integer"
},
"endpoint_id": {
Expand Down Expand Up @@ -875,11 +875,11 @@
},
"SuccessResponseModel": {
"properties": {
"status": {
"status_code": {
"default": 200,
"exclusiveMaximum": 600,
"minimum": 100,
"title": "Status",
"title": "Status Code",
"type": "integer"
},
"success": {
Expand Down Expand Up @@ -919,11 +919,11 @@
},
"ErrorListResponseModel": {
"properties": {
"status": {
"status_code": {
"default": 200,
"exclusiveMaximum": 600,
"minimum": 100,
"title": "Status",
"title": "Status Code",
"type": "integer"
},
"errors": {
Expand Down Expand Up @@ -961,11 +961,11 @@
},
"ScaleResponseModel": {
"properties": {
"status": {
"status_code": {
"default": 200,
"exclusiveMaximum": 600,
"minimum": 100,
"title": "Status",
"title": "Status Code",
"type": "integer"
},
"current_route_count": {
Expand Down Expand Up @@ -1044,11 +1044,11 @@
},
"TokenResponseModel": {
"properties": {
"status": {
"status_code": {
"default": 200,
"exclusiveMaximum": 600,
"minimum": 100,
"title": "Status",
"title": "Status Code",
"type": "integer"
},
"token": {
Expand Down Expand Up @@ -1082,11 +1082,11 @@
},
"SessionStatusResponseModel": {
"properties": {
"status": {
"status_code": {
"default": 200,
"exclusiveMaximum": 600,
"minimum": 100,
"title": "Status",
"title": "Status Code",
"type": "integer"
},
"session_status_map": {
Expand Down Expand Up @@ -1177,11 +1177,11 @@
},
"ConvertSessionToImageResponseModel": {
"properties": {
"status": {
"status_code": {
"default": 200,
"exclusiveMaximum": 600,
"minimum": 100,
"title": "Status",
"title": "Status Code",
"type": "integer"
},
"task_id": {
Expand Down
4 changes: 2 additions & 2 deletions src/ai/backend/manager/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async def wrapped(request: web.Request, *args: P.args, **kwargs: P.kwargs) -> TA


class BaseResponseModel(BaseModel):
status: Annotated[int, Field(strict=True, exclude=True, ge=100, lt=600)] = 200
status_code: Annotated[int, Field(strict=True, exclude=True, ge=100, lt=600)] = 200


TParamModel = TypeVar("TParamModel", bound=BaseModel)
Expand All @@ -235,7 +235,7 @@ def ensure_stream_response_type(
response: BaseResponseModel | BaseModel | list[TResponseModel] | web.StreamResponse,
) -> web.StreamResponse:
match response:
case BaseResponseModel(status=status):
case BaseResponseModel(status_code=status):
return web.json_response(response.model_dump(mode="json"), status=status)
case BaseModel():
return web.json_response(response.model_dump(mode="json"))
Expand Down
71 changes: 71 additions & 0 deletions src/ai/backend/manager/api/vfolders/protocols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import uuid
from typing import (
Protocol,
Sequence,
)

from aiohttp import web

from .types import (
CreatedResponseModel,
Keypair,
NoContentResponseModel,
UserIdentity,
VFolderCreateRequestModel,
VFolderCreateRequirements,
VFolderCreateResponseModel,
VFolderDeleteRequestModel,
VFolderList,
VFolderListRequestModel,
VFolderListResponseModel,
VFolderMetadata,
VFolderRenameRequestModel,
)


class VFolderHandlerProtocol(Protocol):
async def create_vfolder(
self, request: web.Request, params: VFolderCreateRequestModel
) -> VFolderCreateResponseModel: ...

async def list_vfolders(
self, request: web.Request, params: VFolderListRequestModel
) -> VFolderListResponseModel: ...

async def rename_vfodler(
self, request: web.Request, params: VFolderRenameRequestModel
) -> CreatedResponseModel: ...

async def delete_vfolder(
self, request: web.Request, params: VFolderDeleteRequestModel
) -> NoContentResponseModel: ...


class VFolderServiceProtocol(Protocol):
async def create_vfolder_in_personal(
self,
user_identity: UserIdentity,
keypair: Keypair,
vfolder_create_requirements: VFolderCreateRequirements,
) -> VFolderMetadata: ...

async def create_vfolder_in_group(
self,
user_identity: UserIdentity,
keypair: Keypair,
vfolder_create_requirements: VFolderCreateRequirements,
) -> VFolderMetadata: ...

async def get_vfolders(self, user_identity: UserIdentity) -> VFolderList: ...

async def rename_vfolder(
self, user_identity: UserIdentity, vfolder_id: uuid.UUID, new_name: str
) -> None: ...

async def delete_vfolder(
self,
vfolder_id: uuid.UUID,
user_identity: UserIdentity,
allowed_vfolder_types: Sequence[str],
keypair: Keypair,
) -> None: ...
Loading

0 comments on commit b910b73

Please sign in to comment.