fix: recover eligible model GPU routes

This commit is contained in:
CoolBoy
2026-09-20 10:47:22 +08:00
parent 3077b169c5
commit 75c034d588
13 changed files with 436 additions and 29 deletions

View File

@@ -36,9 +36,41 @@ def parse_model_submission_precheck(payload: Any) -> dict[str, Any]:
if not isinstance(verify_result, dict):
raise ModelHubAPIError("Community model precheck verifyResult is invalid", payload=payload)
blocked_gpus: set[str] = set()
failed_frameworks_by_gpu: dict[str, set[str]] = {}
for gpu, gpu_result in verify_result.items():
name = str(gpu)
if not isinstance(gpu_result, dict):
blocked_gpus.add(name)
continue
status = str(gpu_result.get("result") or "").strip()
records = gpu_result.get("records")
if status == "未验证" and isinstance(records, list) and not records:
continue
if status == "验证失败" and isinstance(records, list) and records:
frameworks: set[str] = set()
for record in records:
if not isinstance(record, dict):
break
framework = str(record.get("framework") or "").strip()
try:
failed = int(record.get("verifyResult")) < 0
except (TypeError, ValueError):
failed = False
if not framework or not failed:
break
frameworks.add(framework)
else:
failed_frameworks_by_gpu[name] = frameworks
continue
# Verified, validating and unknown states remain closed. A failed GPU
# opens only for a different framework with explicit failed records.
blocked_gpus.add(name)
return {
"isInDB": data.get("isInDB") is True,
"processedGpus": set(str(gpu) for gpu in verify_result),
"processedGpus": blocked_gpus,
"failedFrameworksByGpu": failed_frameworks_by_gpu,
"verifyResult": verify_result,
"modelInfo": data.get("modelInfo") if isinstance(data.get("modelInfo"), dict) else {},
}
@@ -73,10 +105,7 @@ class ModelHubClient:
return parse_model_submission_precheck(self.search_by_model_id(model_id, force_refresh=force_refresh))
def is_model_processed_for_gpu(self, model_id: str, target_gpu: str) -> bool:
gpu_result = self.get_verify_result_map(model_id).get(target_gpu)
if gpu_result is None:
return False
return "result" in gpu_result or "records" in gpu_result
return target_gpu in self.model_submission_precheck(model_id)["processedGpus"]
def get_verify_result_map(self, model_id: str) -> dict[str, Any]:
payload = self.search_by_model_id(model_id)