File size: 2,741 Bytes
b67c03f 5f8f821 bf2fa25 5f8f821 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | from src.bucket import summarize_run_bundle
def test_summarize_run_bundle_uses_gate_and_smoke():
bundle = {
"state": {
"kind": "universal_model_card_builder",
"model_id": "Tongyi-MAI/Z-Image-Turbo",
"target_space": "alice/z-image",
"job_url": "https://huggingface.co/jobs/alice/123",
},
"inference_gate": {"status": "manual_hardware_required", "manual_hardware_required": True, "implementation_signals": {"health_passed": True}},
"generation_smoke": {"status": "success", "ok": True, "latency_seconds": 18.7, "expected_output_type": "image"},
"hardware_strategy": {"selected_hardware": "l40sx1"},
}
summary = summarize_run_bundle("run-123", bundle, bucket_source="alice/space-factory-runs")
assert summary["status"] == "manual_hardware_required"
assert summary["model_id"] == "Tongyi-MAI/Z-Image-Turbo"
assert summary["selected_hardware"] == "l40sx1"
assert summary["manual_hardware_required"] is True
assert summary["health_passed"] is True
assert summary["smoke_test_passed"] is True
assert summary["latency_seconds"] == 18.7
def test_summarize_run_bundle_recovers_launch_only_running_job():
bundle = {
"launch": {
"kind": "universal_model_card_builder",
"status": "running",
"model_id": "Tongyi-MAI/Z-Image-Turbo",
"target_space": "alice/z-image",
"job_id": "abc123",
"job_url": "https://huggingface.co/jobs/alice/abc123",
"created_by": "alice",
"preferred_space_hardware": "zero-a10g",
}
}
summary = summarize_run_bundle("run-launch", bundle, bucket_source="alice/space-factory-runs")
assert summary["status"] == "running"
assert summary["model_id"] == "Tongyi-MAI/Z-Image-Turbo"
assert summary["target_space"] == "alice/z-image"
assert summary["job_id"] == "abc123"
assert summary["job_url"].endswith("/abc123")
assert summary["artifacts_url"].endswith("/tree/runs/run-launch")
def test_summarize_run_bundle_uses_summary_file_fallback():
bundle = {
"summary_file": {
"status": "running",
"model_id": "owner/model",
"target_space": "alice/generated-space",
"job_id": "job-from-summary",
"job_url": "https://huggingface.co/jobs/alice/job-from-summary",
}
}
summary = summarize_run_bundle("run-summary", bundle, bucket_source="alice/space-factory-runs")
assert summary["status"] == "running"
assert summary["model_id"] == "owner/model"
assert summary["job_id"] == "job-from-summary"
assert summary["target_space_url"].endswith("/alice/generated-space")
|