Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Refactor model service status mapping and improve validation logs
Browse files
backend/app/services/models.py
CHANGED
|
@@ -9,8 +9,7 @@ import asyncio
|
|
| 9 |
import time
|
| 10 |
from huggingface_hub import HfApi, CommitOperationAdd
|
| 11 |
from huggingface_hub.utils import build_hf_headers
|
| 12 |
-
import
|
| 13 |
-
from datasets import load_dataset, disable_progress_bar
|
| 14 |
import sys
|
| 15 |
import contextlib
|
| 16 |
from concurrent.futures import ThreadPoolExecutor
|
|
@@ -158,9 +157,9 @@ class ModelService(HuggingFaceService):
|
|
| 158 |
status = content.get("status", "PENDING").upper()
|
| 159 |
target_status = None
|
| 160 |
status_map = {
|
| 161 |
-
"PENDING": ["PENDING"
|
| 162 |
"EVALUATING": ["RUNNING"],
|
| 163 |
-
"FINISHED": ["FINISHED"
|
| 164 |
}
|
| 165 |
|
| 166 |
for target, source_statuses in status_map.items():
|
|
@@ -425,6 +424,17 @@ class ModelService(HuggingFaceService):
|
|
| 425 |
logger.error(LogFormatter.error("Failed to check existing submissions", e))
|
| 426 |
raise
|
| 427 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
# Validate model card
|
| 429 |
valid, error, model_card = await self.validator.check_model_card(
|
| 430 |
model_data["model_id"]
|
|
@@ -541,7 +551,7 @@ class ModelService(HuggingFaceService):
|
|
| 541 |
|
| 542 |
return {
|
| 543 |
"status": "success",
|
| 544 |
-
"message": "
|
| 545 |
}
|
| 546 |
|
| 547 |
async def get_model_status(self, model_id: str) -> Dict[str, Any]:
|
|
|
|
| 9 |
import time
|
| 10 |
from huggingface_hub import HfApi, CommitOperationAdd
|
| 11 |
from huggingface_hub.utils import build_hf_headers
|
| 12 |
+
from datasets import disable_progress_bar
|
|
|
|
| 13 |
import sys
|
| 14 |
import contextlib
|
| 15 |
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
| 157 |
status = content.get("status", "PENDING").upper()
|
| 158 |
target_status = None
|
| 159 |
status_map = {
|
| 160 |
+
"PENDING": ["PENDING"],
|
| 161 |
"EVALUATING": ["RUNNING"],
|
| 162 |
+
"FINISHED": ["FINISHED"]
|
| 163 |
}
|
| 164 |
|
| 165 |
for target, source_statuses in status_map.items():
|
|
|
|
| 424 |
logger.error(LogFormatter.error("Failed to check existing submissions", e))
|
| 425 |
raise
|
| 426 |
|
| 427 |
+
# Check that model on hub and valid
|
| 428 |
+
valid, error, model_config = await self.validator.is_model_on_hub(
|
| 429 |
+
model_data["model_id"],
|
| 430 |
+
model_data["revision"],
|
| 431 |
+
test_tokenizer=True
|
| 432 |
+
)
|
| 433 |
+
if not valid:
|
| 434 |
+
logger.error(LogFormatter.error("Model on hub validation failed", error))
|
| 435 |
+
raise Exception(error)
|
| 436 |
+
logger.info(LogFormatter.success("Model on hub validation passed"))
|
| 437 |
+
|
| 438 |
# Validate model card
|
| 439 |
valid, error, model_card = await self.validator.check_model_card(
|
| 440 |
model_data["model_id"]
|
|
|
|
| 551 |
|
| 552 |
return {
|
| 553 |
"status": "success",
|
| 554 |
+
"message": "The model was submitted successfully, and the vote has been recorded"
|
| 555 |
}
|
| 556 |
|
| 557 |
async def get_model_status(self, model_id: str) -> Dict[str, Any]:
|