from pathlib import Path import gradio as gr HERE = Path(__file__).parent def read_card_body() -> str: text = (HERE / "README.md").read_text(encoding="utf-8") if text.startswith("---"): parts = text.split("---", 2) if len(parts) == 3: return parts[2].lstrip() return text def budget_views() -> tuple[str, str]: """Build the public budget-decision chart + telemetry note. Returns ("","") on ANY failure so the Space always renders at least the card (no hard dependency).""" try: import hub_charts return (hub_charts.build_html(HERE / "data" / "results.jsonl"), hub_charts.build_telemetry_note()) except Exception: # noqa: BLE001 - a chart error must never break the Space return "", "" chart_html, telemetry_html = budget_views() with gr.Blocks(title="RTX PRO 4000 Hub") as demo: if chart_html: gr.HTML(chart_html) if telemetry_html: gr.HTML(telemetry_html) gr.Markdown(read_card_body()) if __name__ == "__main__": demo.launch()