Spaces:
Running on Zero
Running on Zero
Publish GPU worker reports back to the workspace
Browse files51 unmodified lines5253545556575859606162636416 unmodified lines8182838485868751 unmodified linesadapter = TransformersLocalAdapter(model_id=model_id, model=model, tokenizer=tokenizer)path = Path(tempfile.gettempdir()) / f"harnesslab-hf-{uuid4()}.json"batch = evaluate_case(adapter, case_id, model_id, getattr(model.config, "_commit_hash", None), root, path)from space_app import store_reportreport_id = store_report(batch, "real_live")result = batch.summary()result["workspace_report"] = f"/?report={report_id}"result["failure_reason"] = batch.cases[0].report.evaluation.failure_reasonreturn result, str(path)@spaces.GPU(duration=10)def gpu_environment_check() -> dict[str, str | float]:"""Optional real CUDA check; never invoked during startup or Mock runs."""16 unmodified linesexecute = gr.Button("실제 모델 평가 실행 — ZeroGPU 사용", variant="primary")summary = gr.JSON(label="실제 실행 결과")artifact = gr.File(label="평가 Trace JSON 다운로드")execute.click(run_model, inputs=[scenario], outputs=[summary, artifact], api_name="evaluate_model", concurrency_limit=1)gr.Markdown("## 선택: GPU 환경 확인\n버튼을 누를 때만 ZeroGPU 쿼터를 사용합니다(요청 최대 10초). Mock 평가와 기록 조회에는 필요하지 않습니다.")diagnostic = gr.Button("GPU 환경 확인 — ZeroGPU 쿼터 사용")gpu_result = gr.JSON(label="환경 확인 결과 — 모델 성능 지표가 아닙니다")51 unmodified lines525354555657585960616263646566676816 unmodified lines858687888990919251 unmodified linesadapter = TransformersLocalAdapter(model_id=model_id, model=model, tokenizer=tokenizer)path = Path(tempfile.gettempdir()) / f"harnesslab-hf-{uuid4()}.json"batch = evaluate_case(adapter, case_id, model_id, getattr(model.config, "_commit_hash", None), root, path)result = batch.summary()result["failure_reason"] = batch.cases[0].report.evaluation.failure_reasonreturn result, str(path)def publish_result(result: dict, path: str) -> dict:# GPU functions run in an isolated worker; update the web process here.from harness.batch import load_batchfrom space_app import store_reportreport_id = store_report(load_batch(Path(path)), "real_live")return {**result, "workspace_report": f"/?report={report_id}"}@spaces.GPU(duration=10)def gpu_environment_check() -> dict[str, str | float]:"""Optional real CUDA check; never invoked during startup or Mock runs."""16 unmodified linesexecute = gr.Button("실제 모델 평가 실행 — ZeroGPU 사용", variant="primary")summary = gr.JSON(label="실제 실행 결과")artifact = gr.File(label="평가 Trace JSON 다운로드")event = execute.click(run_model, inputs=[scenario], outputs=[summary, artifact], api_name="evaluate_model", concurrency_limit=1)event.then(publish_result, inputs=[summary, artifact], outputs=[summary], api_name=False)gr.Markdown("## 선택: GPU 환경 확인\n버튼을 누를 때만 ZeroGPU 쿼터를 사용합니다(요청 최대 10초). Mock 평가와 기록 조회에는 필요하지 않습니다.")diagnostic = gr.Button("GPU 환경 확인 — ZeroGPU 쿼터 사용")gpu_result = gr.JSON(label="환경 확인 결과 — 모델 성능 지표가 아닙니다")
app.py+9-4