Skip to content

Commit 1ec2730

Browse files
committed
fix(BA-5829): clean BEP refs, drop unused type:ignore, break circular import
Per #11285 review: - Strip the BEP-1052 §X annotations from descriptions, comments, and docstrings — the BEP number doesn't help future readers and clutters the schema. - Move `BulkCreate/UpdateMyAppConfigFragmentsPayloadGQL` from `app_config_fragment/types/bulk_payloads.py` into `app_config/types/bulk_payloads.py`. They referenced `AppConfigGQL` while `AppConfigGQL` already references `AppConfigFragmentGQL`, so splitting them keeps the import direction one-way and resolves the `tests/component/user/test_keypair_ops.py` collection error reported by `test-component`. - Drop unused `# type: ignore[misc]` on `gql_mutation` decorators (the helper preserves the wrapped function's signature, so mypy no longer treats the result as untyped).
1 parent ab0e0a6 commit 1ec2730

23 files changed

Lines changed: 113 additions & 99 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
AppConfig (merged view) DTOs v2 for Manager API (BEP-1052 §5).
2+
AppConfig (merged view) DTOs v2 for Manager API.
33
"""
44

55
from .request import (

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Request DTOs for AppConfig (merged view) DTO v2 (BEP-1052 §5).
2+
Request DTOs for AppConfig (merged view) DTO v2.
33
"""
44

55
from __future__ import annotations
@@ -62,7 +62,7 @@ class SearchMyAppConfigsInput(_AppConfigSearchInputBase):
6262
"""Input for self-service merged-view search (`/v2/app-configs/my/search`).
6363
6464
The adapter pins the caller as the user scope; no `user_id` argument
65-
is accepted here (BEP-1052 §5 — `filter.userId` is ignored).
65+
is accepted here.
6666
"""
6767

6868

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Response DTOs for AppConfig (merged view) DTO v2 (BEP-1052 §5).
2+
Response DTOs for AppConfig (merged view) DTO v2.
33
"""
44

55
from __future__ import annotations
@@ -25,7 +25,7 @@
2525

2626

2727
class AppConfigNode(BaseResponseModel):
28-
"""Merged per-user AppConfig view (BEP-1052 §5).
28+
"""Merged per-user AppConfig view.
2929
3030
`fragments` are ordered low → high merge priority (matching the
3131
policy's `scope_sources`). `config` is the deep-merged result,
@@ -66,7 +66,7 @@ class BulkCreateMyAppConfigFragmentsPayload(BaseResponseModel):
6666
"""Payload for `bulkCreateMyAppConfigFragments`.
6767
6868
Each successfully created row produces a recomputed merged
69-
`AppConfigNode`; failures are collected per-item (BEP-1052 §3).
69+
`AppConfigNode`; failures are collected per-item.
7070
"""
7171

7272
created: list[AppConfigNode] = Field(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Common types for AppConfig (merged view) DTO v2 (BEP-1052 §5).
2+
Common types for AppConfig (merged view) DTO v2.
33
"""
44

55
from __future__ import annotations

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

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""AppConfig (merged view) domain adapter — BEP-1052 §5.
1+
"""AppConfig (merged view) domain adapter
22
33
Reads the per-user merged AppConfig view and writes the underlying USER
44
fragments via the same `app_config_fragment` service processors. The
@@ -69,7 +69,7 @@
6969

7070

7171
class AppConfigAdapter(BaseAdapter):
72-
"""Adapter for the merged AppConfig view (BEP-1052 §5).
72+
"""Adapter for the merged AppConfig view.
7373
7474
Backed by the `app_config_fragment` service processors — the merged
7575
view is computed from raw fragments — but exposed as a separate
@@ -146,7 +146,7 @@ async def admin_search_app_configs(
146146
has_previous_page=result.has_previous_page,
147147
)
148148

149-
# ── Self-service bulk writes (BEP-1052 §3) ───────────────────────
149+
# ── Self-service bulk writes ───────────────────────
150150
#
151151
# Each bulk processor returns a `BulkProcessResult[T]` whose
152152
# `.result` field is the underlying `*ActionResult` produced by the
@@ -156,19 +156,12 @@ async def admin_search_app_configs(
156156
async def my_bulk_create(
157157
self, input: BulkCreateMyAppConfigFragmentsInput
158158
) -> BulkCreateMyAppConfigFragmentsPayload:
159-
me = current_user()
160-
if me is None:
161-
raise UnreachableError("User context is not available")
162159
items = [
163160
MyAppConfigFragmentBulkItem(name=item.name, extra_config=dict(item.extra_config))
164161
for item in input.items
165162
]
166163
wrapper = await self._processors.app_config_fragment.bulk_create_my.wait_for_complete(
167-
BulkCreateMyAppConfigFragmentsAction(
168-
entity_ids=[],
169-
user_id=me.user_id,
170-
items=items,
171-
)
164+
BulkCreateMyAppConfigFragmentsAction(entity_ids=[], items=items)
172165
)
173166
result = wrapper.result
174167
return BulkCreateMyAppConfigFragmentsPayload(
@@ -179,19 +172,12 @@ async def my_bulk_create(
179172
async def my_bulk_update(
180173
self, input: BulkUpdateMyAppConfigFragmentsInput
181174
) -> BulkUpdateMyAppConfigFragmentsPayload:
182-
me = current_user()
183-
if me is None:
184-
raise UnreachableError("User context is not available")
185175
items = [
186176
MyAppConfigFragmentBulkItem(name=item.name, extra_config=dict(item.extra_config))
187177
for item in input.items
188178
]
189179
wrapper = await self._processors.app_config_fragment.bulk_update_my.wait_for_complete(
190-
BulkUpdateMyAppConfigFragmentsAction(
191-
entity_ids=[],
192-
user_id=me.user_id,
193-
items=items,
194-
)
180+
BulkUpdateMyAppConfigFragmentsAction(entity_ids=[], items=items)
195181
)
196182
result = wrapper.result
197183
return BulkUpdateMyAppConfigFragmentsPayload(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@
6969

7070

7171
class AppConfigFragmentAdapter(BaseAdapter):
72-
"""Adapter for AppConfigFragment raw-row operations (BEP-1052 §2).
72+
"""Adapter for AppConfigFragment raw-row operations.
7373
74-
Writes are bulk-only (BEP-1052 §3); single-item create / update /
74+
Writes are bulk-only; single-item create / update /
7575
purge entry points are intentionally absent. Self-service my_bulk
7676
writes (which return the recomputed merged view) live on
7777
`AppConfigAdapter` alongside the merged-view reads.
@@ -226,7 +226,7 @@ def _data_to_dto(data: AppConfigFragmentData) -> AppConfigFragmentNode:
226226
updated_at=data.updated_at,
227227
)
228228

229-
# ── Bulk mutations (BEP-1052 §3) ───────────────────────────────
229+
# ── Bulk mutations ───────────────────────────────
230230
#
231231
# Each bulk processor returns a `BulkProcessResult[T]` whose
232232
# `.result` field is the underlying `*ActionResult` produced by the

src/ai/backend/manager/api/gql/app_config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""AppConfig (merged view) GraphQL API package (BEP-1052 §5)."""
1+
"""AppConfig (merged view) GraphQL API package."""
22

33
from .resolver import (
44
admin_app_configs,

src/ai/backend/manager/api/gql/app_config/resolver/query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""AppConfig (merged view) GQL query resolvers (BEP-1052 §5)."""
1+
"""AppConfig (merged view) GQL query resolvers."""
22

33
from __future__ import annotations
44

@@ -36,7 +36,7 @@
3636
added_version=NEXT_RELEASE_VERSION,
3737
description=(
3838
"Caller's own merged AppConfig list (auth required). Chain per policy "
39-
"(BEP-1052 §5); the adapter pins `(USER, current_user)` internally."
39+
"; the adapter pins `(USER, current_user)` internally."
4040
),
4141
)
4242
) # type: ignore[misc]
@@ -108,7 +108,7 @@ async def admin_app_configs(
108108
added_version=NEXT_RELEASE_VERSION,
109109
description=(
110110
"Public (no-auth) `PUBLIC`-scope app-config fragments — the subset of "
111-
"raw fragments that carry no personally-scoped data (BEP-1052 §3)."
111+
"raw fragments that carry no personally-scoped data."
112112
),
113113
)
114114
) # type: ignore[misc]

src/ai/backend/manager/api/gql/app_config/types/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from .bulk_payloads import (
2+
BulkCreateMyAppConfigFragmentsPayloadGQL,
3+
BulkUpdateMyAppConfigFragmentsPayloadGQL,
4+
)
15
from .filters import (
26
AppConfigFilterGQL,
37
AppConfigOrderByGQL,
@@ -10,4 +14,6 @@
1014
"AppConfigGQL",
1115
"AppConfigOrderByGQL",
1216
"AppConfigOrderFieldGQL",
17+
"BulkCreateMyAppConfigFragmentsPayloadGQL",
18+
"BulkUpdateMyAppConfigFragmentsPayloadGQL",
1319
]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""AppConfig (merged-view) GQL payloads for self-service bulk mutations."""
2+
3+
from __future__ import annotations
4+
5+
from ai.backend.common.dto.manager.v2.app_config.response import (
6+
BulkCreateMyAppConfigFragmentsPayload as BulkCreateMyPayloadDTO,
7+
)
8+
from ai.backend.common.dto.manager.v2.app_config.response import (
9+
BulkUpdateMyAppConfigFragmentsPayload as BulkUpdateMyPayloadDTO,
10+
)
11+
from ai.backend.common.meta.meta import NEXT_RELEASE_VERSION
12+
from ai.backend.manager.api.gql.app_config.types.node import AppConfigGQL
13+
from ai.backend.manager.api.gql.app_config_fragment.types.bulk_payloads import (
14+
AppConfigFragmentBulkErrorGQL,
15+
)
16+
from ai.backend.manager.api.gql.decorators import (
17+
BackendAIGQLMeta,
18+
gql_field,
19+
gql_pydantic_type,
20+
)
21+
from ai.backend.manager.api.gql.pydantic_compat import PydanticOutputMixin
22+
23+
24+
@gql_pydantic_type(
25+
BackendAIGQLMeta(
26+
added_version=NEXT_RELEASE_VERSION,
27+
description="Payload for `bulkCreateMyAppConfigFragments` (recomputed views).",
28+
),
29+
model=BulkCreateMyPayloadDTO,
30+
name="BulkCreateMyAppConfigFragmentsPayload",
31+
)
32+
class BulkCreateMyAppConfigFragmentsPayloadGQL(PydanticOutputMixin[BulkCreateMyPayloadDTO]):
33+
created: list[AppConfigGQL] = gql_field(
34+
description="Recomputed merged AppConfig views for each created USER fragment.",
35+
)
36+
failed: list[AppConfigFragmentBulkErrorGQL] = gql_field(
37+
description="Per-item failures.",
38+
)
39+
40+
41+
@gql_pydantic_type(
42+
BackendAIGQLMeta(
43+
added_version=NEXT_RELEASE_VERSION,
44+
description="Payload for `bulkUpdateMyAppConfigFragments` (recomputed views).",
45+
),
46+
model=BulkUpdateMyPayloadDTO,
47+
name="BulkUpdateMyAppConfigFragmentsPayload",
48+
)
49+
class BulkUpdateMyAppConfigFragmentsPayloadGQL(PydanticOutputMixin[BulkUpdateMyPayloadDTO]):
50+
updated: list[AppConfigGQL] = gql_field(
51+
description="Recomputed merged AppConfig views for each updated USER fragment.",
52+
)
53+
failed: list[AppConfigFragmentBulkErrorGQL] = gql_field(
54+
description="Per-item failures.",
55+
)

0 commit comments

Comments
 (0)