Skip to content

Commit cd97203

Browse files
fregataaclaude
andcommitted
fix(BA-3692): Fix action signatures and scope types for list/search operations
- Changed ListModelServiceAction and SearchServicesAction to use USER scope instead of PROJECT scope - Removed _project_id field and replaced with _user_id in action results - Fixed handler to not access non-existent .success attribute on action results - Removed unused result variables in update_route and delete_route handlers These changes fix the mypy errors in PR #10033: 1. Missing positional argument "_project_id" - fixed by removing it and using USER scope 2. ActionResult has no attribute "success" - fixed by using SuccessResponseModel(success=True) directly Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 2396c0a commit cd97203

4 files changed

Lines changed: 18 additions & 20 deletions

File tree

src/ai/backend/manager/api/rest/service/handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ async def update_route(
469469
traffic_ratio=params.traffic_ratio,
470470
)
471471

472-
result = await self._model_serving.update_route.wait_for_complete(action)
472+
await self._model_serving.update_route.wait_for_complete(action)
473473

474-
resp = SuccessResponseModel(success=result.success)
474+
resp = SuccessResponseModel(success=True)
475475
return APIResponse.build(HTTPStatus.OK, resp)
476476

477477
# ------------------------------------------------------------------
@@ -494,9 +494,9 @@ async def delete_route(
494494
route_id=path_params.route_id,
495495
)
496496

497-
result = await self._model_serving.delete_route.wait_for_complete(action)
497+
await self._model_serving.delete_route.wait_for_complete(action)
498498

499-
resp = SuccessResponseModel(success=result.success)
499+
resp = SuccessResponseModel(success=True)
500500
return APIResponse.build(HTTPStatus.OK, resp)
501501

502502
# ------------------------------------------------------------------

src/ai/backend/manager/services/model_serving/actions/list_model_service.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
class ListModelServiceAction(ModelServiceScopeAction):
1717
session_owener_id: uuid.UUID
1818
name: str | None
19-
_project_id: uuid.UUID
2019

2120
@override
2221
@classmethod
@@ -25,26 +24,26 @@ def operation_type(cls) -> ActionOperationType:
2524

2625
@override
2726
def scope_type(self) -> ScopeType:
28-
return ScopeType.PROJECT
27+
return ScopeType.USER
2928

3029
@override
3130
def scope_id(self) -> str:
32-
return str(self._project_id)
31+
return str(self.session_owener_id)
3332

3433
@override
3534
def target_element(self) -> RBACElementRef:
36-
return RBACElementRef(RBACElementType.PROJECT, str(self._project_id))
35+
return RBACElementRef(RBACElementType.USER, str(self.session_owener_id))
3736

3837

3938
@dataclass
4039
class ListModelServiceActionResult(ModelServiceScopeActionResult):
4140
data: list[CompactServiceInfo]
42-
_project_id: uuid.UUID
41+
_user_id: uuid.UUID
4342

4443
@override
4544
def scope_type(self) -> ScopeType:
46-
return ScopeType.PROJECT
45+
return ScopeType.USER
4746

4847
@override
4948
def scope_id(self) -> str:
50-
return str(self._project_id)
49+
return str(self._user_id)

src/ai/backend/manager/services/model_serving/actions/search_services.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
@dataclass
1717
class SearchServicesAction(ModelServiceScopeAction):
1818
session_owner_id: uuid.UUID
19-
_project_id: uuid.UUID
2019
conditions: list[QueryCondition] = field(default_factory=list)
2120
offset: int = 0
2221
limit: int = 20
@@ -28,15 +27,15 @@ def operation_type(cls) -> ActionOperationType:
2827

2928
@override
3029
def scope_type(self) -> ScopeType:
31-
return ScopeType.PROJECT
30+
return ScopeType.USER
3231

3332
@override
3433
def scope_id(self) -> str:
35-
return str(self._project_id)
34+
return str(self.session_owner_id)
3635

3736
@override
3837
def target_element(self) -> RBACElementRef:
39-
return RBACElementRef(RBACElementType.PROJECT, str(self._project_id))
38+
return RBACElementRef(RBACElementType.USER, str(self.session_owner_id))
4039

4140

4241
@dataclass
@@ -45,12 +44,12 @@ class SearchServicesActionResult(ModelServiceScopeActionResult):
4544
total_count: int
4645
offset: int
4746
limit: int
48-
_project_id: uuid.UUID
47+
_user_id: uuid.UUID
4948

5049
@override
5150
def scope_type(self) -> ScopeType:
52-
return ScopeType.PROJECT
51+
return ScopeType.USER
5352

5453
@override
5554
def scope_id(self) -> str:
56-
return str(self._project_id)
55+
return str(self._user_id)

src/ai/backend/manager/services/model_serving/services/model_serving.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ async def list_serve(self, action: ListModelServiceAction) -> ListModelServiceAc
415415
)
416416
for endpoint in endpoints
417417
],
418-
_project_id=action._project_id,
418+
_user_id=action.session_owener_id,
419419
)
420420

421421
async def search_services(self, action: SearchServicesAction) -> SearchServicesActionResult:
@@ -429,7 +429,7 @@ async def search_services(self, action: SearchServicesAction) -> SearchServicesA
429429
total_count=result.total_count,
430430
offset=action.offset,
431431
limit=action.limit,
432-
_project_id=action._project_id,
432+
_user_id=action.session_owner_id,
433433
)
434434

435435
async def check_user_access(self) -> None:

0 commit comments

Comments
 (0)