refactor(BA-6619): consolidate AppConfigScopeType into common.data (single definition)#12403
Conversation
…ingle definition) AppConfigScopeType was defined three times — in the app_config_allow_list DTO, the app_config_allow_list data, and the app_config_fragment data. Define it once in ai.backend.common.data.app_config.types (with the to_rbac_scope_type/to_rbac_scope_id helpers) and have every layer (data, DTO, GraphQL, models, repositories, client, tests) import it directly from there. No re-exports: the DTO types module keeps the import only for its filter model and drops it from __all__. Split out of the AppConfigFragment service PR (BA-6554) to land at the base of the stack. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR removes a duplicated AppConfigScopeType enum that had drifted into three separate definitions (the app_config_allow_list DTO, the app_config_allow_list data module, and the app_config_fragment data module) and replaces them with a single source of truth in a new ai.backend.common.data.app_config.types module. Every layer — data, DTO, GraphQL, models, repositories, client/CLI, and tests — now imports the enum directly from common.data, with no re-exports. It is the base PR of the BEP-1052 AppConfigFragment/AppConfig stack, deliberately landed first so the enum consolidation is independent of the downstream service/API PRs.
Changes:
- Adds
common/data/app_config/types.pycontaining the singleAppConfigScopeTypeplus newto_rbac_scope_type/to_rbac_scope_idhelpers (the helpers are foundation for the later service layer and are not yet consumed). - Deletes the three duplicate
class AppConfigScopeTypedefinitions and repoints all importers (including the DTO module, which keeps the import only for itsAppConfigScopeTypeFilterand drops the enum from__all__). - Updates all affected unit tests to import from the new location.
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ai/backend/common/data/app_config/types.py | New single definition of AppConfigScopeType with RBAC scope helpers. |
| src/ai/backend/common/data/app_config/init.py | New empty package marker. |
| src/ai/backend/common/dto/manager/v2/app_config_allow_list/types.py | Drops the local enum class and re-imports it from common.data for the filter model; removes it from __all__. |
| src/ai/backend/common/dto/manager/v2/app_config_allow_list/request.py | Repoints AppConfigScopeType import to common.data. |
| src/ai/backend/common/dto/manager/v2/app_config_allow_list/response.py | Repoints AppConfigScopeType import to common.data. |
| src/ai/backend/manager/data/app_config_allow_list/types.py | Removes the duplicate enum; imports from common.data. |
| src/ai/backend/manager/data/app_config_fragment/types.py | Removes the duplicate enum; imports from common.data. |
| src/ai/backend/manager/models/app_config_allow_list/row.py | Repoints enum import. |
| src/ai/backend/manager/models/app_config_allow_list/conditions.py | Repoints enum import. |
| src/ai/backend/manager/models/app_config_fragment/row.py | Repoints enum import. |
| src/ai/backend/manager/models/app_config_fragment/conditions.py | Repoints enum import. |
| src/ai/backend/manager/repositories/app_config_allow_list/creators.py | Repoints enum import. |
| src/ai/backend/manager/repositories/app_config_fragment/creators.py | Repoints enum import. |
| src/ai/backend/manager/api/gql/app_config_allow_list/types.py | Repoints enum import to common.data, keeps the DTO filter alias. |
| src/ai/backend/manager/api/adapters/app_config_allow_list/adapter.py | Repoints imports; leaves a redundant double-import of the same symbol (see comment). |
| src/ai/backend/client/cli/v2/admin/app_config_allow_list.py | Repoints enum import. |
| tests/unit/... (5 files) | Update test imports to the new location. |
| changes/12403.misc.md | Changelog entry for the consolidation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from ai.backend.common.data.app_config.types import AppConfigScopeType | ||
| from ai.backend.common.data.app_config.types import AppConfigScopeType as AppConfigScopeTypeDTO |
Summary
AppConfigScopeTypewas defined three times — in theapp_config_allow_listDTO, theapp_config_allow_listdata, and theapp_config_fragmentdata. This consolidates it to a single definition inai.backend.common.data.app_config.types(with theto_rbac_scope_type/to_rbac_scope_idhelpers), and has every layer (data, DTO, GraphQL, models, repositories, client, tests) import it directly from there.No re-exports: the DTO
typesmodule keeps the import only for itsAppConfigScopeTypeFiltermodel and drops it from__all__; all other modules import fromcommon.datadirectly.Split out of the AppConfigFragment service PR (#12358) so the enum consolidation lands independently at the base of the stack.
Changes
common/data/app_config/types.py— the singleAppConfigScopeType.class AppConfigScopeTypedefinitions; repointed all importers tocommon.data.📚 Stacked PRs
Part of the AppConfigFragment / AppConfig stack under BEP-1052 (epic BA-5781). Merge in order:
feat(BA-6552): app_config_fragments DB model and Alembic migrationfeat(BA-6553): repository layerrefactor(BA-6619): consolidate AppConfigScopeType into common.data← you are hererefactor(BA-6620): ExistsQuerier + AppConfigAllowList.existsfeat(BA-6554): AppConfigFragment service layerfeat(BA-6618): AppConfigFragment bulk CRUD service layerfeat(BA-6555): app_config service layerfeat(BA-6556): AppConfig REST v2 API