-
Notifications
You must be signed in to change notification settings - Fork 164
refactor: Extract manager setup logic into modular providers #6217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Moved dependency initialization and configuration code from server.py into separate provider modules under `providers/` directory for better separation of concerns and maintainability. Each provider module handles a specific aspect of manager setup: - Database connections and models - Redis clients (image, live, stat, stream, etc.) - Event system (dispatcher, producer, hub) - Background tasks and message queues - Service discovery and leader election - Plugin systems (event dispatcher, hooks, network) - Monitoring and idle checking - Core repositories and services - Sokovan orchestrator 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the manager initialization logic by extracting dependency setup code from a monolithic server.py file into modular provider modules under the providers/ directory. This improves separation of concerns and maintainability by organizing related setup logic into focused modules.
Key changes:
- Extracted context manager functions from
server.pyinto 22 dedicated provider modules - Each provider handles initialization of specific manager subsystems (database, Redis, events, etc.)
- Reduced the size of
server.pyby ~750 lines while preserving existing functionality - Added proper imports for all extracted providers in
server.py
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/ai/backend/manager/server.py |
Removed inline context managers and replaced with imports from provider modules |
src/ai/backend/manager/providers/__init__.py |
Added package initialization with module description |
src/ai/backend/manager/providers/*.py |
22 new provider modules, each handling specific aspect of manager setup (database, Redis, events, etc.) |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| from ai.backend.common import redis_helper | ||
| from ai.backend.common.defs import REDIS_STREAM_LOCK, RedisRole | ||
| from ai.backend.logging.utils import BraceStyleAdapter |
Copilot
AI
Oct 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import path inconsistency: other provider modules use from ai.backend.logging import BraceStyleAdapter while this module uses from ai.backend.logging.utils import BraceStyleAdapter. Should be consistent across all provider modules.
| from ai.backend.logging.utils import BraceStyleAdapter | |
| from ai.backend.logging import BraceStyleAdapter |
| from ..models.storage import StorageSessionManager | ||
|
|
||
| root_ctx.storage_manager = StorageSessionManager(root_ctx.config_provider.config.volumes) | ||
| yield |
Copilot
AI
Oct 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing cleanup logic in the storage manager context. The original code had await root_ctx.storage_manager.aclose() in the finally block, but this extracted version only has yield without proper cleanup.
| yield | |
| try: | |
| yield | |
| finally: | |
| await root_ctx.storage_manager.aclose() |
Moved dependency initialization and configuration code from server.py into separate provider modules under
providers/directory for better separation of concerns and maintainability.Each provider module handles a specific aspect of manager setup:
resolves #3931 (BA-938)
Checklist: (if applicable)
ai.backend.testdocsdirectory