-
Notifications
You must be signed in to change notification settings - Fork 458
Implement device fallback to CPU for preconfigured pipelines #5091
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
base: develop
Are you sure you want to change the base?
Conversation
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 implements a device fallback mechanism for pipelines when their configured device becomes unavailable (e.g., after hardware changes between application restarts). If a pipeline's device is no longer available, it automatically falls back to CPU.
Key Changes
- Added device validation in
get_active_pipeline()to check if the configured device is available - Implemented automatic fallback to "cpu" device with database update when the original device is unavailable
- Added test coverage for the device fallback scenario
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| application/backend/app/services/pipeline_service.py | Implements device validation and fallback logic in get_active_pipeline() |
| application/backend/tests/integration/services/test_pipeline_service.py | Adds test case for device fallback when original device is unavailable |
| application/backend/tests/integration/project_factory.py | Adds device parameter to test factory for configurable device testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return None | ||
|
|
||
| pipeline = Pipeline.model_validate(pipeline_db) | ||
| if not SystemService().validate_device(pipeline.device): |
Copilot
AI
Dec 22, 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.
Creating a new SystemService() instance on every call to get_active_pipeline() is inefficient. Consider injecting SystemService as a dependency in the constructor or caching the instance to avoid repeated instantiation.
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.
It's indeed makes sense to provide the service via constructor using DI mechanism -SystemService is already managed in dependencies.py and can be injected into PipelineService.
📊 Test coverage report
|
Docker Image SizesCPU
GPU
XPU
|
| if pipeline_db is None: | ||
| return None | ||
|
|
||
| pipeline = Pipeline.model_validate(pipeline_db) |
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.
This line can be placed below the if block, so the extra update on L48 can be omitted.
Summary
If a pipeline is loaded and its previous set device is not longer available (for example if a hardware refresh happen between app restarts), then fallback to
cpudeviceHow to test
Checklist