File size: 1,781 Bytes
d5b79ad | 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 64 65 66 67 68 69 70 71 | 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')}")
# Optional extras
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)
# Auto-load on startup
demo.load(fn=refresh, outputs=out)
demo.launch()
|