Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
| 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") | |