Spaces:
Sleeping
Sleeping
fix: create gr.State inside Blocks (KeyError on load) + module-level demo
Browse files
app.py
CHANGED
|
@@ -225,9 +225,11 @@ def _find(flows, company, period, stmt):
|
|
| 225 |
|
| 226 |
# ββ App βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 227 |
def build_app():
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
| 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()
|