Skip to content

Commit 4f0950f

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 8cec165 commit 4f0950f

8 files changed

Lines changed: 32 additions & 46 deletions

File tree

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, config=dict(item.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, config=dict(item.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
@@ -109,9 +109,9 @@
109109

110110

111111
class AppConfigFragmentAdapter(BaseAdapter):
112-
"""Adapter for AppConfigFragment raw-row operations (BEP-1052 §2).
112+
"""Adapter for AppConfigFragment raw-row operations.
113113
114-
Writes are bulk-only (BEP-1052 §3); single-item create / update /
114+
Writes are bulk-only; single-item create / update /
115115
purge entry points are intentionally absent. Self-service my_bulk
116116
writes (which return the recomputed merged view) live on
117117
`AppConfigAdapter` alongside the merged-view reads.
@@ -266,7 +266,7 @@ def _data_to_dto(data: AppConfigFragmentData) -> AppConfigFragmentNode:
266266
updated_at=data.updated_at,
267267
)
268268

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

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .bulk_payloads import (
2-
MyBulkCreateAppConfigFragmentsPayloadGQL,
3-
MyBulkUpdateAppConfigFragmentsPayloadGQL,
2+
BulkCreateMyAppConfigFragmentsPayloadGQL,
3+
BulkUpdateMyAppConfigFragmentsPayloadGQL,
44
)
55
from .filters import (
66
AppConfigFilterGQL,
@@ -14,6 +14,6 @@
1414
"AppConfigGQL",
1515
"AppConfigOrderByGQL",
1616
"AppConfigOrderFieldGQL",
17-
"MyBulkCreateAppConfigFragmentsPayloadGQL",
18-
"MyBulkUpdateAppConfigFragmentsPayloadGQL",
17+
"BulkCreateMyAppConfigFragmentsPayloadGQL",
18+
"BulkUpdateMyAppConfigFragmentsPayloadGQL",
1919
]

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from __future__ import annotations
44

55
from ai.backend.common.dto.manager.v2.app_config.response import (
6-
MyBulkCreateAppConfigFragmentsPayload as MyBulkCreatePayloadDTO,
6+
BulkCreateMyAppConfigFragmentsPayload as BulkCreateMyPayloadDTO,
77
)
88
from ai.backend.common.dto.manager.v2.app_config.response import (
9-
MyBulkUpdateAppConfigFragmentsPayload as MyBulkUpdatePayloadDTO,
9+
BulkUpdateMyAppConfigFragmentsPayload as BulkUpdateMyPayloadDTO,
1010
)
1111
from ai.backend.common.meta.meta import NEXT_RELEASE_VERSION
1212
from ai.backend.manager.api.gql.app_config.types.node import AppConfigGQL
@@ -24,12 +24,12 @@
2424
@gql_pydantic_type(
2525
BackendAIGQLMeta(
2626
added_version=NEXT_RELEASE_VERSION,
27-
description="Payload for `myBulkCreateAppConfigFragments` (recomputed views).",
27+
description="Payload for `bulkCreateMyAppConfigFragments` (recomputed views).",
2828
),
29-
model=MyBulkCreatePayloadDTO,
30-
name="MyBulkCreateAppConfigFragmentsPayload",
29+
model=BulkCreateMyPayloadDTO,
30+
name="BulkCreateMyAppConfigFragmentsPayload",
3131
)
32-
class MyBulkCreateAppConfigFragmentsPayloadGQL(PydanticOutputMixin[MyBulkCreatePayloadDTO]):
32+
class BulkCreateMyAppConfigFragmentsPayloadGQL(PydanticOutputMixin[BulkCreateMyPayloadDTO]):
3333
created: list[AppConfigGQL] = gql_field(
3434
description="Recomputed merged AppConfig views for each created USER fragment.",
3535
)
@@ -41,12 +41,12 @@ class MyBulkCreateAppConfigFragmentsPayloadGQL(PydanticOutputMixin[MyBulkCreateP
4141
@gql_pydantic_type(
4242
BackendAIGQLMeta(
4343
added_version=NEXT_RELEASE_VERSION,
44-
description="Payload for `myBulkUpdateAppConfigFragments` (recomputed views).",
44+
description="Payload for `bulkUpdateMyAppConfigFragments` (recomputed views).",
4545
),
46-
model=MyBulkUpdatePayloadDTO,
47-
name="MyBulkUpdateAppConfigFragmentsPayload",
46+
model=BulkUpdateMyPayloadDTO,
47+
name="BulkUpdateMyAppConfigFragmentsPayload",
4848
)
49-
class MyBulkUpdateAppConfigFragmentsPayloadGQL(PydanticOutputMixin[MyBulkUpdatePayloadDTO]):
49+
class BulkUpdateMyAppConfigFragmentsPayloadGQL(PydanticOutputMixin[BulkUpdateMyPayloadDTO]):
5050
updated: list[AppConfigGQL] = gql_field(
5151
description="Recomputed merged AppConfig views for each updated USER fragment.",
5252
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020

2121
__all__ = [
22-
# Queries — scope-bound list belongs on DomainV2 / UserV2 child fields per BEP-1052
22+
# Queries — scope-bound list belongs on DomainV2 / UserV2 child fields
2323
"app_config_fragment",
2424
"scoped_app_config_fragments",
2525
"admin_app_config_fragments",

src/ai/backend/manager/api/gql/app_config_fragment/resolver/mutation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
from ai.backend.common.meta.meta import NEXT_RELEASE_VERSION
88
from ai.backend.manager.api.gql.app_config.types import (
9-
MyBulkCreateAppConfigFragmentsPayloadGQL,
10-
MyBulkUpdateAppConfigFragmentsPayloadGQL,
9+
BulkCreateMyAppConfigFragmentsPayloadGQL,
10+
BulkUpdateMyAppConfigFragmentsPayloadGQL,
1111
)
1212
from ai.backend.manager.api.gql.app_config_fragment.types import (
1313
AdminBulkCreateAppConfigFragmentInputGQL,
@@ -16,8 +16,8 @@
1616
AdminBulkPurgeAppConfigFragmentsPayloadGQL,
1717
AdminBulkUpdateAppConfigFragmentInputGQL,
1818
AdminBulkUpdateAppConfigFragmentsPayloadGQL,
19-
MyBulkCreateAppConfigFragmentInputGQL,
20-
MyBulkUpdateAppConfigFragmentInputGQL,
19+
BulkCreateMyAppConfigFragmentInputGQL,
20+
BulkUpdateMyAppConfigFragmentInputGQL,
2121
)
2222
from ai.backend.manager.api.gql.decorators import (
2323
BackendAIGQLMeta,
@@ -87,7 +87,7 @@ async def admin_bulk_purge_app_config_fragments(
8787
),
8888
)
8989
)
90-
async def my_bulk_create_app_config_fragments(
90+
async def bulk_create_my_app_config_fragments(
9191
info: Info[StrawberryGQLContext],
9292
input: BulkCreateMyAppConfigFragmentInputGQL,
9393
) -> BulkCreateMyAppConfigFragmentsPayloadGQL:
@@ -104,7 +104,7 @@ async def my_bulk_create_app_config_fragments(
104104
),
105105
)
106106
)
107-
async def my_bulk_update_app_config_fragments(
107+
async def bulk_update_my_app_config_fragments(
108108
info: Info[StrawberryGQLContext],
109109
input: BulkUpdateMyAppConfigFragmentInputGQL,
110110
) -> BulkUpdateMyAppConfigFragmentsPayloadGQL:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""AppConfigFragment GQL query resolvers.
22
3-
Per BEP-1052 §2 the scope-bound list is exposed via child fields on
3+
Per the scope-bound list is exposed via child fields on
44
`DomainV2.appConfigFragments` / `UserV2.appConfigFragments`, not as a
55
root resolver. Only the single-row read and the cross-scope admin
66
search live here. The scope-bound REST endpoint

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"AppConfigFragmentOrderByGQL",
4040
"AppConfigFragmentOrderFieldGQL",
4141
"AppConfigScopeTypeGQL",
42-
"MyBulkCreateAppConfigFragmentInputGQL",
43-
"MyBulkUpdateAppConfigFragmentInputGQL",
42+
"BulkCreateMyAppConfigFragmentInputGQL",
43+
"BulkUpdateMyAppConfigFragmentInputGQL",
4444
"MyAppConfigFragmentItemInputGQL",
4545
"PurgeAppConfigFragmentKeyGQL",
4646
]

0 commit comments

Comments
 (0)