24 lines
1,009 B
Python
24 lines
1,009 B
Python
from __future__ import annotations
|
|
|
|
from django.core.management.base import BaseCommand
|
|
from django.utils import timezone
|
|
|
|
from control_plane.resources.models import Resource
|
|
from model_router.providers import QwenProvider, SolProvider
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = "Check configured model provider health without crashing the control plane."
|
|
|
|
def handle(self, *args, **options):
|
|
for resource in Resource.objects.filter(is_active=True, kind="MODEL"):
|
|
if resource.provider == "opencode":
|
|
status = SolProvider(resource).health()
|
|
elif resource.provider == "local_inference":
|
|
status = QwenProvider(resource).health()
|
|
else:
|
|
status = "UNAVAILABLE"
|
|
resource.health_status = status
|
|
resource.last_health_check_at = timezone.now()
|
|
resource.save(update_fields=["health_status", "last_health_check_at", "updated_at"])
|
|
self.stdout.write(f"{resource.name}: {status}")
|