Spaces:
Running on Zero
Running on Zero
Publish GPU worker reports back to the workspace
Browse files
app.py
CHANGED
|
@@ -52,13 +52,17 @@ def main() -> None:
|
|
| 52 |
adapter = TransformersLocalAdapter(model_id=model_id, model=model, tokenizer=tokenizer)
|
| 53 |
path = Path(tempfile.gettempdir()) / f"harnesslab-hf-{uuid4()}.json"
|
| 54 |
batch = evaluate_case(adapter, case_id, model_id, getattr(model.config, "_commit_hash", None), root, path)
|
| 55 |
-
from space_app import store_report
|
| 56 |
-
report_id = store_report(batch, "real_live")
|
| 57 |
result = batch.summary()
|
| 58 |
-
result["workspace_report"] = f"/?report={report_id}"
|
| 59 |
result["failure_reason"] = batch.cases[0].report.evaluation.failure_reason
|
| 60 |
return result, str(path)
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
@spaces.GPU(duration=10)
|
| 63 |
def gpu_environment_check() -> dict[str, str | float]:
|
| 64 |
"""Optional real CUDA check; never invoked during startup or Mock runs."""
|
|
@@ -81,7 +85,8 @@ def main() -> None:
|
|
| 81 |
execute = gr.Button("실제 모델 평가 실행 — ZeroGPU 사용", variant="primary")
|
| 82 |
summary = gr.JSON(label="실제 실행 결과")
|
| 83 |
artifact = gr.File(label="평가 Trace JSON 다운로드")
|
| 84 |
-
execute.click(run_model, inputs=[scenario], outputs=[summary, artifact], api_name="evaluate_model", concurrency_limit=1)
|
|
|
|
| 85 |
gr.Markdown("## 선택: GPU 환경 확인\n버튼을 누를 때만 ZeroGPU 쿼터를 사용합니다(요청 최대 10초). Mock 평가와 기록 조회에는 필요하지 않습니다.")
|
| 86 |
diagnostic = gr.Button("GPU 환경 확인 — ZeroGPU 쿼터 사용")
|
| 87 |
gpu_result = gr.JSON(label="환경 확인 결과 — 모델 성능 지표가 아닙니다")
|
|
|
|
| 52 |
adapter = TransformersLocalAdapter(model_id=model_id, model=model, tokenizer=tokenizer)
|
| 53 |
path = Path(tempfile.gettempdir()) / f"harnesslab-hf-{uuid4()}.json"
|
| 54 |
batch = evaluate_case(adapter, case_id, model_id, getattr(model.config, "_commit_hash", None), root, path)
|
|
|
|
|
|
|
| 55 |
result = batch.summary()
|
|
|
|
| 56 |
result["failure_reason"] = batch.cases[0].report.evaluation.failure_reason
|
| 57 |
return result, str(path)
|
| 58 |
|
| 59 |
+
def publish_result(result: dict, path: str) -> dict:
|
| 60 |
+
# GPU functions run in an isolated worker; update the web process here.
|
| 61 |
+
from harness.batch import load_batch
|
| 62 |
+
from space_app import store_report
|
| 63 |
+
report_id = store_report(load_batch(Path(path)), "real_live")
|
| 64 |
+
return {**result, "workspace_report": f"/?report={report_id}"}
|
| 65 |
+
|
| 66 |
@spaces.GPU(duration=10)
|
| 67 |
def gpu_environment_check() -> dict[str, str | float]:
|
| 68 |
"""Optional real CUDA check; never invoked during startup or Mock runs."""
|
|
|
|
| 85 |
execute = gr.Button("실제 모델 평가 실행 — ZeroGPU 사용", variant="primary")
|
| 86 |
summary = gr.JSON(label="실제 실행 결과")
|
| 87 |
artifact = gr.File(label="평가 Trace JSON 다운로드")
|
| 88 |
+
event = execute.click(run_model, inputs=[scenario], outputs=[summary, artifact], api_name="evaluate_model", concurrency_limit=1)
|
| 89 |
+
event.then(publish_result, inputs=[summary, artifact], outputs=[summary], api_name=False)
|
| 90 |
gr.Markdown("## 선택: GPU 환경 확인\n버튼을 누를 때만 ZeroGPU 쿼터를 사용합니다(요청 최대 10초). Mock 평가와 기록 조회에는 필요하지 않습니다.")
|
| 91 |
diagnostic = gr.Button("GPU 환경 확인 — ZeroGPU 쿼터 사용")
|
| 92 |
gpu_result = gr.JSON(label="환경 확인 결과 — 모델 성능 지표가 아닙니다")
|