Skip to content

Commit d3d1e2b

Browse files
committed
fix(BA-5829): break AppConfig <-> AppConfigFragment GQL import cycle
`app_config/types/node.py` imports `AppConfigFragmentGQL` (AppConfig's `fragments` field), which loads `app_config_fragment/__init__.py`. That used to eagerly re-export the mutation resolvers, which then imported back from `app_config.types.bulk_payloads` -> `node` (still mid-load) -> ImportError. Three small surgeries break the cycle: - `app_config_fragment/__init__.py` no longer re-exports its resolver symbols; `schema.py` now imports them straight from the resolver submodules. - `app_config/types/__init__.py` no longer re-exports the My-bulk payload GQL types, so loading the package no longer drags in `bulk_payloads.py` before `node.py` finishes. - `mutation.py` imports the My-bulk payload types from the `bulk_payloads` submodule directly. `tests/component/user/test_keypair_ops.py` collection (and the `api-updated` schema-dump step) used to fail because of this cycle.
1 parent 33ca330 commit d3d1e2b

4 files changed

Lines changed: 14 additions & 47 deletions

File tree

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
from .bulk_payloads import (
2-
BulkCreateMyAppConfigFragmentsPayloadGQL,
3-
BulkUpdateMyAppConfigFragmentsPayloadGQL,
4-
)
51
from .filters import (
62
AppConfigFilterGQL,
73
AppConfigOrderByGQL,
@@ -14,6 +10,4 @@
1410
"AppConfigGQL",
1511
"AppConfigOrderByGQL",
1612
"AppConfigOrderFieldGQL",
17-
"BulkCreateMyAppConfigFragmentsPayloadGQL",
18-
"BulkUpdateMyAppConfigFragmentsPayloadGQL",
1913
]
Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,9 @@
1-
"""AppConfigFragment GraphQL API package."""
1+
"""AppConfigFragment GraphQL API package.
22
3-
from .resolver import (
4-
admin_app_config_fragments,
5-
admin_bulk_create_app_config_fragments,
6-
admin_bulk_purge_app_config_fragments,
7-
admin_bulk_update_app_config_fragments,
8-
app_config_fragment,
9-
bulk_create_my_app_config_fragments,
10-
bulk_update_my_app_config_fragments,
11-
)
12-
from .types import (
13-
AppConfigFragmentFilterGQL,
14-
AppConfigFragmentGQL,
15-
AppConfigFragmentKeyInputGQL,
16-
AppConfigFragmentOrderByGQL,
17-
AppConfigFragmentOrderFieldGQL,
18-
AppConfigScopeTypeGQL,
19-
)
20-
21-
__all__ = [
22-
# Queries — scope-bound list belongs on DomainV2 / UserV2 child fields
23-
"app_config_fragment",
24-
"admin_app_config_fragments",
25-
# Bulk mutations
26-
"admin_bulk_create_app_config_fragments",
27-
"admin_bulk_update_app_config_fragments",
28-
"admin_bulk_purge_app_config_fragments",
29-
"bulk_create_my_app_config_fragments",
30-
"bulk_update_my_app_config_fragments",
31-
# Types
32-
"AppConfigFragmentGQL",
33-
"AppConfigScopeTypeGQL",
34-
"AppConfigFragmentFilterGQL",
35-
"AppConfigFragmentOrderByGQL",
36-
"AppConfigFragmentOrderFieldGQL",
37-
"AppConfigFragmentKeyInputGQL",
38-
]
3+
Resolver and type names are re-exported by ``schema.py`` directly via
4+
their submodules to keep this package's ``__init__`` import-light: a
5+
top-level ``from app_config_fragment import ...`` would otherwise drag
6+
in the mutation resolvers, which back-import from
7+
``app_config.types.bulk_payloads`` and form an import cycle when
8+
``AppConfigGQL`` is loading.
9+
"""

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from strawberry import Info
66

77
from ai.backend.common.meta.meta import NEXT_RELEASE_VERSION
8-
from ai.backend.manager.api.gql.app_config.types import (
8+
from ai.backend.manager.api.gql.app_config.types.bulk_payloads import (
99
BulkCreateMyAppConfigFragmentsPayloadGQL,
1010
BulkUpdateMyAppConfigFragmentsPayloadGQL,
1111
)

src/ai/backend/manager/api/gql/schema.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020
my_app_configs,
2121
public_app_config_fragments,
2222
)
23-
from .app_config_fragment import (
24-
admin_app_config_fragments,
23+
from .app_config_fragment.resolver.mutation import (
2524
admin_bulk_create_app_config_fragments,
2625
admin_bulk_purge_app_config_fragments,
2726
admin_bulk_update_app_config_fragments,
28-
app_config_fragment,
2927
bulk_create_my_app_config_fragments,
3028
bulk_update_my_app_config_fragments,
3129
)
30+
from .app_config_fragment.resolver.query import (
31+
admin_app_config_fragments,
32+
app_config_fragment,
33+
)
3234
from .app_config_policy import (
3335
admin_bulk_create_app_config_policies,
3436
admin_bulk_purge_app_config_policies,

0 commit comments

Comments
 (0)