Skip to content

Conversation

@A-Artemis
Copy link
Contributor

@A-Artemis A-Artemis commented Dec 22, 2025

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 cpu device

How to test

Checklist

  • The PR title and description are clear and descriptive
  • I have manually tested the changes
  • All changes are covered by automated tests
  • All related issues are linked to this PR (if applicable)
  • Documentation has been updated (if applicable)

@A-Artemis A-Artemis self-assigned this Dec 22, 2025
Copilot AI review requested due to automatic review settings December 22, 2025 09:22
@A-Artemis A-Artemis requested a review from a team as a code owner December 22, 2025 09:22
@A-Artemis A-Artemis linked an issue Dec 22, 2025 that may be closed by this pull request
@github-actions github-actions bot added TEST Any changes in tests Geti Tune Backend Issues related to Geti Tune Studio backend labels Dec 22, 2025
@A-Artemis A-Artemis changed the title Implement device fallback to CPU for inactive pipelines Implement device fallback to CPU for preconfigured pipelines Dec 22, 2025
Copy link
Contributor

Copilot AI left a 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):
Copy link

Copilot AI Dec 22, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@itallix itallix Dec 23, 2025

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.

@github-actions
Copy link

📊 Test coverage report

Metric Coverage
Lines 40.2%
Functions 34.9%
Branches 84.8%
Statements 40.2%

@github-actions
Copy link

Docker Image Sizes

CPU

Image Size
geti-tune-cpu:pr-5091 2.85G
geti-tune-cpu:sha-c659bd7 2.85G

GPU

Image Size
geti-tune-gpu:pr-5091 10.62G
geti-tune-gpu:sha-c659bd7 10.62G

XPU

Image Size
geti-tune-xpu:pr-5091 8.69G
geti-tune-xpu:sha-c659bd7 8.69G

if pipeline_db is None:
return None

pipeline = Pipeline.model_validate(pipeline_db)
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Geti Tune Backend Issues related to Geti Tune Studio backend TEST Any changes in tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fallback to CPU if preconfigured inference device is unavailable

3 participants