| import json |
| from datetime import datetime |
|
|
| import gradio as gr |
| from huggingface_hub import hf_hub_download |
|
|
| DATASET_REPO = "MatverseHub/WebX" |
| REMOTE_PATH = "metrics/metrics.json" |
|
|
|
|
| def load_metrics(): |
| local_path = hf_hub_download(repo_id=DATASET_REPO, repo_type="dataset", filename=REMOTE_PATH) |
| with open(local_path, "r", encoding="utf-8") as f: |
| payload = json.load(f) |
| return payload |
|
|
|
|
| def render(payload): |
| m = payload.get("metrics", {}) |
| updated_at = payload.get("updated_at") or "?" |
| src = payload.get("source", {}) |
|
|
| lines = [] |
| lines.append(f"Updated: {updated_at}") |
| if src: |
| lines.append(f"Source: {src.get('repo','?')}@{src.get('commit','?')}") |
| lines.append("") |
|
|
| def fmt(key): |
| v = m.get(key) |
| return "?" if v is None else str(v) |
|
|
| lines.append(f"Ω (omega): {fmt('omega')}") |
| lines.append(f"Ψ (psi): {fmt('psi')}") |
| lines.append(f"Θ (theta): {fmt('theta')}") |
| lines.append(f"CVaR: {fmt('cvar')}") |
|
|
| |
| for extra in ["ccr", "viability", "antifragility", "epsilon", "energy", "tau", "delta_i"]: |
| if extra in m: |
| lines.append(f"{extra}: {m.get(extra)}") |
|
|
| return "\n".join(lines) |
|
|
|
|
| with gr.Blocks(title="MatVerse WebX Dashboard") as demo: |
| gr.Markdown( |
| """ |
| # MatVerse WebX Dashboard |
| |
| This dashboard pulls **real metrics** from the WebX dataset (`MatverseHub/WebX`). |
| |
| If it shows `?`, your dataset file is missing or malformed. |
| """ |
| ) |
|
|
| out = gr.Textbox(label="Current Metrics", lines=12) |
|
|
| def refresh(): |
| payload = load_metrics() |
| return render(payload) |
|
|
| btn = gr.Button("Refresh Metrics") |
| btn.click(fn=refresh, outputs=out) |
|
|
| |
| demo.load(fn=refresh, outputs=out) |
|
|
|
|
| demo.launch() |
|
|