Skip to content

Commit 4c61888

Browse files
jopemachineclaude
andcommitted
refactor(BA-5836): rename my_bulk_*, drop BEP refs, log.warning, StrEnum match
- Rename `bulk_create_my` / `bulk_update_my` → `my_bulk_create` / `my_bulk_update` across action classes, files, service methods, processors, and the request DTO module to match the existing `my_` prefix convention used elsewhere in the v2 surface (e.g. `my_keypair`). - Switch order-field dispatch in `AppConfigFragmentAdapter` from string `.value` matching to direct StrEnum matching against `AppConfigFragmentOrderField`. - Promote per-item bulk failure logs from `log.debug` to `log.warning`. - Drop BEP-1052 §X references from doctrings, comments, and inline notes across the service / adapter / DTO modules. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 279b023 commit 4c61888

10 files changed

Lines changed: 76 additions & 73 deletions

File tree

src/ai/backend/common/dto/manager/v2/app_config_fragment/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
AppConfigFragmentFilter,
77
AppConfigFragmentKeyInput,
88
AppConfigFragmentOrder,
9-
BulkCreateMyAppConfigFragmentsInput,
10-
BulkUpdateMyAppConfigFragmentsInput,
119
MyAppConfigFragmentItemInput,
10+
MyBulkCreateAppConfigFragmentsInput,
11+
MyBulkUpdateAppConfigFragmentsInput,
1212
SearchAppConfigFragmentsInput,
1313
)
1414
from .response import (
@@ -42,8 +42,8 @@
4242
"AppConfigFragmentOrder",
4343
"AppConfigFragmentOrderField",
4444
"AppConfigScopeType",
45-
"BulkCreateMyAppConfigFragmentsInput",
46-
"BulkUpdateMyAppConfigFragmentsInput",
45+
"MyBulkCreateAppConfigFragmentsInput",
46+
"MyBulkUpdateAppConfigFragmentsInput",
4747
"GetAppConfigFragmentPayload",
4848
"MyAppConfigFragmentItemInput",
4949
"OrderDirection",

src/ai/backend/common/dto/manager/v2/app_config_fragment/request.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"AppConfigFragmentFilter",
2222
"AppConfigFragmentKeyInput",
2323
"AppConfigFragmentOrder",
24-
"BulkCreateMyAppConfigFragmentsInput",
25-
"BulkUpdateMyAppConfigFragmentsInput",
24+
"MyBulkCreateAppConfigFragmentsInput",
25+
"MyBulkUpdateAppConfigFragmentsInput",
2626
"MyAppConfigFragmentItemInput",
2727
"SearchAppConfigFragmentsInput",
2828
)
@@ -56,7 +56,7 @@ class AppConfigFragmentOrder(BaseRequestModel):
5656
direction: OrderDirection = Field(default=OrderDirection.ASC, description="Order direction.")
5757

5858

59-
# ── Bulk mutation inputs (BEP-1052 §3) ───────────────────────────
59+
# ── Bulk mutation inputs ─────────────────────────────────────────
6060

6161

6262
class AdminAppConfigFragmentItemInput(BaseRequestModel):
@@ -93,11 +93,11 @@ class MyAppConfigFragmentItemInput(BaseRequestModel):
9393
)
9494

9595

96-
class BulkCreateMyAppConfigFragmentsInput(BaseRequestModel):
96+
class MyBulkCreateAppConfigFragmentsInput(BaseRequestModel):
9797
items: list[MyAppConfigFragmentItemInput] = Field(description="USER-scope rows to create.")
9898

9999

100-
class BulkUpdateMyAppConfigFragmentsInput(BaseRequestModel):
100+
class MyBulkUpdateAppConfigFragmentsInput(BaseRequestModel):
101101
items: list[MyAppConfigFragmentItemInput] = Field(description="USER-scope rows to update.")
102102

103103

src/ai/backend/common/dto/manager/v2/app_config_fragment/response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class SearchAppConfigFragmentsPayload(BaseResponseModel):
5555
has_previous_page: bool = Field(default=False, description="Whether there is a previous page.")
5656

5757

58-
# ── Bulk mutation payloads (BEP-1052 §3, bulk-only writes) ───────
58+
# ── Bulk mutation payloads (bulk-only writes) ────────────────────
5959

6060

6161
class AppConfigFragmentBulkError(BaseResponseModel):
@@ -99,7 +99,7 @@ class AdminBulkPurgeAppConfigFragmentsPayload(BaseResponseModel):
9999
failed: list[AppConfigFragmentBulkError] = Field(description="Per-item failures.")
100100

101101

102-
# `BulkCreateMyAppConfigFragmentsPayload` / `BulkUpdateMyAppConfigFragmentsPayload`
102+
# `MyBulkCreateAppConfigFragmentsPayload` / `MyBulkUpdateAppConfigFragmentsPayload`
103103
# return recomputed merged `AppConfig` views — they live in
104104
# `common/dto/manager/v2/app_config/response.py` (added with the
105105
# merged-view DTO in the GQL/REST layer) to keep `AppConfigNode` as the

src/ai/backend/common/dto/manager/v2/app_config_fragment/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
class AppConfigScopeType(StrEnum):
19-
"""Scope types for app-config fragments (BEP-1052 §1)."""
19+
"""Scope types for app-config fragments."""
2020

2121
PUBLIC = "public"
2222
DOMAIN = "domain"

src/ai/backend/manager/api/adapters/app_config_fragment.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
PurgeAppConfigFragmentKey,
2222
SearchAppConfigFragmentsPayload,
2323
)
24+
from ai.backend.common.dto.manager.v2.app_config_fragment.types import (
25+
AppConfigFragmentOrderField,
26+
OrderDirection,
27+
)
2428
from ai.backend.common.dto.manager.v2.app_config_fragment.types import (
2529
AppConfigScopeType as DTOAppConfigScopeType,
2630
)
27-
from ai.backend.common.dto.manager.v2.app_config_fragment.types import OrderDirection
2831
from ai.backend.manager.api.adapter_options.pagination.pagination import PaginationSpec
2932
from ai.backend.manager.data.app_config_fragment.bulk_types import (
3033
AppConfigFragmentBulkItem,
@@ -63,11 +66,11 @@
6366

6467

6568
class AppConfigFragmentAdapter(BaseAdapter):
66-
"""Adapter for AppConfigFragment domain operations (BEP-1052 §2).
69+
"""Adapter for AppConfigFragment domain operations.
6770
68-
Writes are bulk-only (BEP-1052 §3); single-item create / update /
69-
purge entry points are intentionally absent. Self-service my_bulk
70-
methods are added with the merged-view DTOs in BA-5829.
71+
Writes are bulk-only; single-item create / update / purge entry
72+
points are intentionally absent. Self-service my_bulk methods are
73+
added with the merged-view DTOs in BA-5829.
7174
"""
7275

7376
async def get(self, key_input: AppConfigFragmentKeyInput) -> GetAppConfigFragmentPayload:
@@ -186,16 +189,16 @@ def _convert_orders(orders: list[AppConfigFragmentOrder]) -> list[QueryOrder]:
186189
result: list[QueryOrder] = []
187190
for order in orders:
188191
ascending = order.direction == OrderDirection.ASC
189-
match order.field.value:
190-
case "scope_type":
192+
match order.field:
193+
case AppConfigFragmentOrderField.SCOPE_TYPE:
191194
result.append(AppConfigFragmentOrders.scope_type(ascending))
192-
case "scope_id":
195+
case AppConfigFragmentOrderField.SCOPE_ID:
193196
result.append(AppConfigFragmentOrders.scope_id(ascending))
194-
case "name":
197+
case AppConfigFragmentOrderField.NAME:
195198
result.append(AppConfigFragmentOrders.name(ascending))
196-
case "created_at":
199+
case AppConfigFragmentOrderField.CREATED_AT:
197200
result.append(AppConfigFragmentOrders.created_at(ascending))
198-
case "updated_at":
201+
case AppConfigFragmentOrderField.UPDATED_AT:
199202
result.append(AppConfigFragmentOrders.updated_at(ascending))
200203
return result
201204

@@ -219,7 +222,7 @@ def _data_to_dto(data: AppConfigFragmentData) -> AppConfigFragmentNode:
219222
updated_at=data.updated_at,
220223
)
221224

222-
# ── Bulk mutations (BEP-1052 §3) ───────────────────────────────
225+
# ── Bulk mutations ─────────────────────────────────────────────
223226
#
224227
# Each bulk processor returns a `BulkProcessResult[T]` whose
225228
# `.result` field is the underlying `*ActionResult` produced by the

src/ai/backend/manager/data/app_config_fragment/bulk_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Bulk-mutation service-layer dataclasses for app_config_fragments (BEP-1052 §3)."""
1+
"""Bulk-mutation service-layer dataclasses for app_config_fragments."""
22

33
from __future__ import annotations
44

@@ -31,7 +31,7 @@ class MyAppConfigFragmentBulkItem:
3131

3232
@dataclass(frozen=True)
3333
class AppConfigFragmentBulkItemError:
34-
"""Per-item failure carried through bulk action results (BEP-1052 §3).
34+
"""Per-item failure carried through bulk action results.
3535
3636
`scope_type` / `scope_id` / `name` identify which input row failed;
3737
`index` preserves the caller's original list position.

src/ai/backend/manager/services/app_config_fragment/actions/bulk_create_my.py renamed to src/ai/backend/manager/services/app_config_fragment/actions/my_bulk_create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
@dataclass
17-
class BulkCreateMyAppConfigFragmentsAction(BaseBulkAction[MyAppConfigFragmentBulkItem]):
17+
class MyBulkCreateAppConfigFragmentsAction(BaseBulkAction[MyAppConfigFragmentBulkItem]):
1818
"""Self-service bulk create — scope is `USER` / `current_user.user_id`.
1919
2020
The owning `user_id` is resolved from the request `ContextVar`
@@ -41,7 +41,7 @@ def operation_type(cls) -> ActionOperationType:
4141

4242

4343
@dataclass
44-
class BulkCreateMyAppConfigFragmentsActionResult(BaseBulkActionResult):
44+
class MyBulkCreateAppConfigFragmentsActionResult(BaseBulkActionResult):
4545
"""`created` carries the recomputed merged view per successfully
4646
created fragment; `failed` carries per-item errors.
4747
"""

src/ai/backend/manager/services/app_config_fragment/actions/bulk_update_my.py renamed to src/ai/backend/manager/services/app_config_fragment/actions/my_bulk_update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
@dataclass
17-
class BulkUpdateMyAppConfigFragmentsAction(BaseBulkAction[MyAppConfigFragmentBulkItem]):
17+
class MyBulkUpdateAppConfigFragmentsAction(BaseBulkAction[MyAppConfigFragmentBulkItem]):
1818
"""Self-service bulk update — see `BulkCreateMyAppConfigFragmentsAction`."""
1919

2020
items: list[MyAppConfigFragmentBulkItem] = field(default_factory=list)
@@ -35,7 +35,7 @@ def operation_type(cls) -> ActionOperationType:
3535

3636

3737
@dataclass
38-
class BulkUpdateMyAppConfigFragmentsActionResult(BaseBulkActionResult):
38+
class MyBulkUpdateAppConfigFragmentsActionResult(BaseBulkActionResult):
3939
updated: list[AppConfigData]
4040
failed: list[AppConfigFragmentBulkItemError]
4141

src/ai/backend/manager/services/app_config_fragment/processors.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
AdminSearchAppConfigFragmentsAction,
2222
AdminSearchAppConfigFragmentsActionResult,
2323
)
24-
from ai.backend.manager.services.app_config_fragment.actions.bulk_create_my import (
25-
BulkCreateMyAppConfigFragmentsAction,
26-
BulkCreateMyAppConfigFragmentsActionResult,
27-
)
28-
from ai.backend.manager.services.app_config_fragment.actions.bulk_update_my import (
29-
BulkUpdateMyAppConfigFragmentsAction,
30-
BulkUpdateMyAppConfigFragmentsActionResult,
31-
)
3224
from ai.backend.manager.services.app_config_fragment.actions.get import (
3325
GetAppConfigFragmentAction,
3426
GetAppConfigFragmentActionResult,
3527
)
28+
from ai.backend.manager.services.app_config_fragment.actions.my_bulk_create import (
29+
MyBulkCreateAppConfigFragmentsAction,
30+
MyBulkCreateAppConfigFragmentsActionResult,
31+
)
32+
from ai.backend.manager.services.app_config_fragment.actions.my_bulk_update import (
33+
MyBulkUpdateAppConfigFragmentsAction,
34+
MyBulkUpdateAppConfigFragmentsActionResult,
35+
)
3636
from ai.backend.manager.services.app_config_fragment.actions.search import (
3737
SearchAppConfigFragmentsAction,
3838
SearchAppConfigFragmentsActionResult,
@@ -46,10 +46,10 @@ class AppConfigFragmentProcessors(AbstractProcessorPackage):
4646
admin_search: ActionProcessor[
4747
AdminSearchAppConfigFragmentsAction, AdminSearchAppConfigFragmentsActionResult
4848
]
49-
# Bulk mutations (BEP-1052 §3) — wrapped by BulkActionProcessor so
50-
# validators (RBAC, etc.) can filter entity_ids per-item before the
51-
# service runs. No bulk validators are wired today; the processor
52-
# simply forwards to the service.
49+
# Bulk mutations — wrapped by BulkActionProcessor so validators
50+
# (RBAC, etc.) can filter entity_ids per-item before the service
51+
# runs. No bulk validators are wired today; the processor simply
52+
# forwards to the service.
5353
admin_bulk_create: BulkActionProcessor[
5454
AdminBulkCreateAppConfigFragmentsAction, AdminBulkCreateAppConfigFragmentsActionResult
5555
]
@@ -59,11 +59,11 @@ class AppConfigFragmentProcessors(AbstractProcessorPackage):
5959
admin_bulk_purge: BulkActionProcessor[
6060
AdminBulkPurgeAppConfigFragmentsAction, AdminBulkPurgeAppConfigFragmentsActionResult
6161
]
62-
bulk_create_my: BulkActionProcessor[
63-
BulkCreateMyAppConfigFragmentsAction, BulkCreateMyAppConfigFragmentsActionResult
62+
my_bulk_create: BulkActionProcessor[
63+
MyBulkCreateAppConfigFragmentsAction, MyBulkCreateAppConfigFragmentsActionResult
6464
]
65-
bulk_update_my: BulkActionProcessor[
66-
BulkUpdateMyAppConfigFragmentsAction, BulkUpdateMyAppConfigFragmentsActionResult
65+
my_bulk_update: BulkActionProcessor[
66+
MyBulkUpdateAppConfigFragmentsAction, MyBulkUpdateAppConfigFragmentsActionResult
6767
]
6868

6969
def __init__(
@@ -78,8 +78,8 @@ def __init__(
7878
self.admin_bulk_create = BulkActionProcessor(service.admin_bulk_create, action_monitors)
7979
self.admin_bulk_update = BulkActionProcessor(service.admin_bulk_update, action_monitors)
8080
self.admin_bulk_purge = BulkActionProcessor(service.admin_bulk_purge, action_monitors)
81-
self.bulk_create_my = BulkActionProcessor(service.bulk_create_my, action_monitors)
82-
self.bulk_update_my = BulkActionProcessor(service.bulk_update_my, action_monitors)
81+
self.my_bulk_create = BulkActionProcessor(service.my_bulk_create, action_monitors)
82+
self.my_bulk_update = BulkActionProcessor(service.my_bulk_update, action_monitors)
8383

8484
@override
8585
def supported_actions(self) -> list[ActionSpec]:
@@ -90,6 +90,6 @@ def supported_actions(self) -> list[ActionSpec]:
9090
AdminBulkCreateAppConfigFragmentsAction.spec(),
9191
AdminBulkUpdateAppConfigFragmentsAction.spec(),
9292
AdminBulkPurgeAppConfigFragmentsAction.spec(),
93-
BulkCreateMyAppConfigFragmentsAction.spec(),
94-
BulkUpdateMyAppConfigFragmentsAction.spec(),
93+
MyBulkCreateAppConfigFragmentsAction.spec(),
94+
MyBulkUpdateAppConfigFragmentsAction.spec(),
9595
]

0 commit comments

Comments
 (0)