ninarg commited on
Commit
2c65c14
Β·
verified Β·
1 Parent(s): 355f477

fix: create gr.State inside Blocks (KeyError on load) + module-level demo

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -225,9 +225,11 @@ def _find(flows, company, period, stmt):
225
 
226
  # ── App ───────────────────────────────────────────────────────────────────────
227
  def build_app():
228
- state = gr.State(_demo_flows())
229
-
230
- with gr.Blocks(title="Financial Sankey Explorer", theme=gr.themes.Soft()) as demo:
 
 
231
  gr.Markdown(
232
  "# πŸ’Έ Financial Sankey Explorer\n"
233
  "Multi-step funds-flow view of synthetic financial statements from "
@@ -284,5 +286,8 @@ def build_app():
284
  return demo
285
 
286
 
 
 
 
287
  if __name__ == "__main__":
288
- build_app().launch()
 
225
 
226
  # ── App ───────────────────────────────────────────────────────────────────────
227
  def build_app():
228
+ with gr.Blocks(title="Financial Sankey Explorer") as demo:
229
+ # State MUST be created inside the Blocks context so it is registered
230
+ # (a State created outside has an unregistered id β†’ KeyError on every
231
+ # callback that reads it, including the on-load).
232
+ state = gr.State(_demo_flows())
233
  gr.Markdown(
234
  "# πŸ’Έ Financial Sankey Explorer\n"
235
  "Multi-step funds-flow view of synthetic financial statements from "
 
286
  return demo
287
 
288
 
289
+ # Module-level `demo` so the HF Spaces launcher auto-detects it.
290
+ demo = build_app()
291
+
292
  if __name__ == "__main__":
293
+ demo.launch()