Spaces:
Sleeping
Sleeping
Upload backend/core/management/commands/retry_ingestion_job.py with huggingface_hub
Browse files
backend/core/management/commands/retry_ingestion_job.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.core.management.base import BaseCommand, CommandError
|
| 2 |
+
|
| 3 |
+
from hue_portal.core.models import IngestionJob
|
| 4 |
+
from hue_portal.core.tasks import process_ingestion_job
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class Command(BaseCommand):
|
| 8 |
+
help = "Retry a failed ingestion job by ID"
|
| 9 |
+
|
| 10 |
+
def add_arguments(self, parser):
|
| 11 |
+
parser.add_argument("job_id", help="UUID of the ingestion job to retry")
|
| 12 |
+
|
| 13 |
+
def handle(self, job_id, **options):
|
| 14 |
+
try:
|
| 15 |
+
job = IngestionJob.objects.get(id=job_id)
|
| 16 |
+
except IngestionJob.DoesNotExist as exc:
|
| 17 |
+
raise CommandError(f"Ingestion job {job_id} not found") from exc
|
| 18 |
+
|
| 19 |
+
job.status = IngestionJob.STATUS_PENDING
|
| 20 |
+
job.error_message = ""
|
| 21 |
+
job.progress = 0
|
| 22 |
+
job.save(update_fields=["status", "error_message", "progress", "updated_at"])
|
| 23 |
+
process_ingestion_job.delay(str(job.id))
|
| 24 |
+
self.stdout.write(self.style.SUCCESS(f"Re-queued ingestion job {job.id}"))
|
| 25 |
+
|