Skip to content

Commit b3b1cfa

Browse files
jopemachineclaude
andcommitted
refactor(BA-5832): tighten admin CLI types, propagate my_bulk rename, drop BEP refs
- Type the admin AppConfig CLI's `user_id` argument and `--user-id` flag as `click.UUID` (was `str` parsed via `UUID(...)`); the SDK already takes `UUID` so this drops a redundant runtime parse and surfaces bad input at click parse time. Also wrap the search filter's `user_id` in `UUIDFilter`, matching the DTO shape. - Carry the `bulk_create_my` / `bulk_update_my` → `my_bulk_create` / `my_bulk_update` rename through the v2 SDK (`domains_v2/app_config.py`), the self-service CLI (`cli/v2/my/app_config.py`), and the remaining GQL / adapter / service touchpoints that leaked through `-X theirs` during the stack rebase. - Strip the residual `BEP-1052 §X` references from CLI / SDK docstrings and the GraphQL schema dump comments. Only the news fragments retain the BEP wording. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 127f637 commit b3b1cfa

23 files changed

Lines changed: 127 additions & 128 deletions

File tree

src/ai/backend/client/cli/v2/admin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def invitation() -> None:
211211
name="app-config",
212212
)
213213
def app_config() -> None:
214-
"""Admin merged AppConfig commands (BEP-1052 §5)."""
214+
"""Admin merged AppConfig commands."""
215215

216216

217217
@admin.group(

src/ai/backend/client/cli/v2/admin/app_config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Admin CLI commands for the merged AppConfig view (BEP-1052 §5)."""
1+
"""Admin CLI commands for the merged AppConfig view."""
22

33
from __future__ import annotations
44

@@ -21,15 +21,15 @@ def app_config() -> None:
2121

2222

2323
@app_config.command()
24-
@click.argument("user_id", type=str)
24+
@click.argument("user_id", type=click.UUID)
2525
@click.argument("name", type=str)
26-
def get(user_id: str, name: str) -> None:
26+
def get(user_id: UUID, name: str) -> None:
2727
"""Read a specific user's merged AppConfig (admin only)."""
2828

2929
async def _run() -> None:
3030
registry = await create_v2_registry(load_v2_config())
3131
try:
32-
result = await registry.app_config.admin_get(UUID(user_id), name)
32+
result = await registry.app_config.admin_get(user_id, name)
3333
print_result(result)
3434
finally:
3535
await registry.close()
@@ -41,7 +41,7 @@ async def _run() -> None:
4141
@click.option("--limit", type=int, default=None, help="Maximum items to return.")
4242
@click.option("--offset", type=int, default=None, help="Number of items to skip.")
4343
@click.option("--name-contains", type=str, default=None, help="Filter `name` by substring.")
44-
@click.option("--user-id", type=str, default=None, help="Pin to a single user (UUID).")
44+
@click.option("--user-id", type=click.UUID, default=None, help="Pin to a single user (UUID).")
4545
@click.option(
4646
"--order-by",
4747
multiple=True,
@@ -51,11 +51,11 @@ def search(
5151
limit: int | None,
5252
offset: int | None,
5353
name_contains: str | None,
54-
user_id: str | None,
54+
user_id: UUID | None,
5555
order_by: tuple[str, ...],
5656
) -> None:
5757
"""Cross-user merged-view search (superadmin only)."""
58-
from ai.backend.common.dto.manager.query import StringFilter
58+
from ai.backend.common.dto.manager.query import StringFilter, UUIDFilter
5959
from ai.backend.common.dto.manager.v2.app_config.request import (
6060
AppConfigFilter,
6161
AppConfigOrder,
@@ -67,7 +67,7 @@ def search(
6767
if name_contains is not None or user_id is not None:
6868
filter_dto = AppConfigFilter(
6969
name=StringFilter(contains=name_contains) if name_contains is not None else None,
70-
user_id=UUID(user_id) if user_id is not None else None,
70+
user_id=UUIDFilter(equals=user_id) if user_id is not None else None,
7171
)
7272

7373
orders = (

src/ai/backend/client/cli/v2/admin/app_config_policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Admin CLI commands for AppConfigPolicy (bulk-only writes, BEP-1052 §3)."""
1+
"""Admin CLI commands for AppConfigPolicy (bulk-only writes)."""
22

33
from __future__ import annotations
44

src/ai/backend/client/cli/v2/app_config/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""CLI commands for the merged AppConfig view (BEP-1052 §5).
1+
"""CLI commands for the merged AppConfig view.
22
33
Public entrypoint exposes only the read paths that any authenticated
44
user can hit. Self-service writes live under `bai my app-config`;

src/ai/backend/client/cli/v2/my/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ def storage_host() -> None:
9090
name="app-config",
9191
)
9292
def app_config() -> None:
93-
"""My merged AppConfig commands (BEP-1052 §5)."""
93+
"""My merged AppConfig commands."""

src/ai/backend/client/cli/v2/my/app_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Self-service CLI commands for the merged AppConfig view (BEP-1052 §5)."""
1+
"""Self-service CLI commands for the merged AppConfig view."""
22

33
from __future__ import annotations
44

@@ -88,8 +88,8 @@ def _load_items(items_arg: str) -> list[dict[str, Any]]:
8888
def bulk_create(items: str) -> None:
8989
"""Bulk-create USER-scope fragments; returns recomputed merged views."""
9090
from ai.backend.common.dto.manager.v2.app_config_fragment.request import (
91-
BulkCreateMyAppConfigFragmentsInput,
9291
MyAppConfigFragmentItemInput,
92+
MyBulkCreateAppConfigFragmentsInput,
9393
)
9494

9595
parsed = [MyAppConfigFragmentItemInput.model_validate(item) for item in _load_items(items)]
@@ -98,7 +98,7 @@ async def _run() -> None:
9898
registry = await create_v2_registry(load_v2_config())
9999
try:
100100
result = await registry.app_config.my_bulk_create(
101-
BulkCreateMyAppConfigFragmentsInput(items=parsed),
101+
MyBulkCreateAppConfigFragmentsInput(items=parsed),
102102
)
103103
print_result(result)
104104
finally:
@@ -116,8 +116,8 @@ async def _run() -> None:
116116
def bulk_update(items: str) -> None:
117117
"""Bulk-update USER-scope fragments; returns recomputed merged views."""
118118
from ai.backend.common.dto.manager.v2.app_config_fragment.request import (
119-
BulkUpdateMyAppConfigFragmentsInput,
120119
MyAppConfigFragmentItemInput,
120+
MyBulkUpdateAppConfigFragmentsInput,
121121
)
122122

123123
parsed = [MyAppConfigFragmentItemInput.model_validate(item) for item in _load_items(items)]
@@ -126,7 +126,7 @@ async def _run() -> None:
126126
registry = await create_v2_registry(load_v2_config())
127127
try:
128128
result = await registry.app_config.my_bulk_update(
129-
BulkUpdateMyAppConfigFragmentsInput(items=parsed),
129+
MyBulkUpdateAppConfigFragmentsInput(items=parsed),
130130
)
131131
print_result(result)
132132
finally:

src/ai/backend/client/v2/domains_v2/app_config.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""V2 SDK client for the merged AppConfig view (BEP-1052 §5).
1+
"""V2 SDK client for the merged AppConfig view.
22
33
Replaces the legacy upsert-style domain/user app-config SDK; the new
44
surface is bulk-only writes against `USER`-scope fragments plus
@@ -15,14 +15,14 @@
1515
SearchMyAppConfigsInput,
1616
)
1717
from ai.backend.common.dto.manager.v2.app_config.response import (
18-
BulkCreateMyAppConfigFragmentsPayload,
19-
BulkUpdateMyAppConfigFragmentsPayload,
2018
GetUserAppConfigPayload,
19+
MyBulkCreateAppConfigFragmentsPayload,
20+
MyBulkUpdateAppConfigFragmentsPayload,
2121
SearchAppConfigsPayload,
2222
)
2323
from ai.backend.common.dto.manager.v2.app_config_fragment.request import (
24-
BulkCreateMyAppConfigFragmentsInput,
25-
BulkUpdateMyAppConfigFragmentsInput,
24+
MyBulkCreateAppConfigFragmentsInput,
25+
MyBulkUpdateAppConfigFragmentsInput,
2626
)
2727

2828
_PATH = "/v2/app-configs"
@@ -67,23 +67,23 @@ async def admin_search(self, request: SearchAppConfigsInput) -> SearchAppConfigs
6767
)
6868

6969
async def my_bulk_create(
70-
self, request: BulkCreateMyAppConfigFragmentsInput
71-
) -> BulkCreateMyAppConfigFragmentsPayload:
70+
self, request: MyBulkCreateAppConfigFragmentsInput
71+
) -> MyBulkCreateAppConfigFragmentsPayload:
7272
"""Bulk-create USER-scope fragments; returns recomputed merged views."""
7373
return await self._client.typed_request(
7474
"POST",
7575
f"{_FRAGMENT_PATH}/my/bulk-create",
7676
request=request,
77-
response_model=BulkCreateMyAppConfigFragmentsPayload,
77+
response_model=MyBulkCreateAppConfigFragmentsPayload,
7878
)
7979

8080
async def my_bulk_update(
81-
self, request: BulkUpdateMyAppConfigFragmentsInput
82-
) -> BulkUpdateMyAppConfigFragmentsPayload:
81+
self, request: MyBulkUpdateAppConfigFragmentsInput
82+
) -> MyBulkUpdateAppConfigFragmentsPayload:
8383
"""Bulk-update USER-scope fragments; returns recomputed merged views."""
8484
return await self._client.typed_request(
8585
"POST",
8686
f"{_FRAGMENT_PATH}/my/bulk-update",
8787
request=request,
88-
response_model=BulkUpdateMyAppConfigFragmentsPayload,
88+
response_model=MyBulkUpdateAppConfigFragmentsPayload,
8989
)

src/ai/backend/client/v2/domains_v2/app_config_fragment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""V2 SDK client for the app-config fragment domain (BEP-1052 §2).
1+
"""V2 SDK client for the app-config fragment domain.
22
33
Fragments are an admin-only surface — end users interact with the merged
44
``AppConfig`` view (``V2AppConfigClient``) instead. Self-service
@@ -28,7 +28,7 @@
2828
class V2AppConfigFragmentClient(BaseDomainClient):
2929
"""SDK client for AppConfigFragment admin operations.
3030
31-
Writes are bulk-only (BEP-1052 §3).
31+
Writes are bulk-only.
3232
"""
3333

3434
async def admin_search(

src/ai/backend/client/v2/domains_v2/app_config_policy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""V2 SDK client for the app-config policy domain (BEP-1052 §1).
1+
"""V2 SDK client for the app-config policy domain.
22
33
Policies are an admin-only surface — end users observe their effects
44
through the merged ``AppConfig`` view (``V2AppConfigClient``), not by
@@ -25,7 +25,7 @@
2525
class V2AppConfigPolicyClient(BaseDomainClient):
2626
"""SDK client for AppConfigPolicy admin operations.
2727
28-
Writes are bulk-only (BEP-1052 §3); single-item create / update /
28+
Writes are bulk-only; single-item create / update /
2929
purge are intentionally absent.
3030
"""
3131

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
)
1212
from .response import (
1313
AppConfigNode,
14-
BulkCreateMyAppConfigFragmentsPayload,
15-
BulkUpdateMyAppConfigFragmentsPayload,
1614
GetUserAppConfigPayload,
15+
MyBulkCreateAppConfigFragmentsPayload,
16+
MyBulkUpdateAppConfigFragmentsPayload,
1717
SearchAppConfigsPayload,
1818
)
1919
from .types import (
@@ -28,8 +28,8 @@
2828
"AppConfigOrder",
2929
"AppConfigOrderField",
3030
"AppConfigScopeType",
31-
"BulkCreateMyAppConfigFragmentsPayload",
32-
"BulkUpdateMyAppConfigFragmentsPayload",
31+
"MyBulkCreateAppConfigFragmentsPayload",
32+
"MyBulkUpdateAppConfigFragmentsPayload",
3333
"GetUserAppConfigInput",
3434
"GetUserAppConfigPayload",
3535
"OrderDirection",

0 commit comments

Comments
 (0)