Yiyu Tian commited on
Commit
8c1267a
·
1 Parent(s): d3dc705

Patch Gradio schema crash: handle boolean additionalProperties

Browse files

gradio_client.utils._json_schema_to_python_type crashes when
additionalProperties is True (boolean) instead of a dict — complex
gr.State types trigger this. Patch returns "Any" for non-dict input.

Also removes the ineffective GRADIO_SSR_MODE env var workaround.

Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -22,8 +22,16 @@ from datetime import datetime, timezone
22
  from pathlib import Path
23
 
24
  import gradio as gr
 
25
  import pandas as pd
26
 
 
 
 
 
 
 
 
27
  from evaluate_runner import DIFFICULTY_MULTIPLIER, DEFAULT_SERVER, compute_composite_score, compute_game_metrics
28
 
29
  logger = logging.getLogger(__name__)
@@ -1777,8 +1785,6 @@ def build_app() -> gr.Blocks:
1777
  return app
1778
 
1779
 
1780
- os.environ["GRADIO_SSR_MODE"] = "false"
1781
-
1782
  if __name__ == "__main__":
1783
  app = build_app()
1784
  app.launch(
 
22
  from pathlib import Path
23
 
24
  import gradio as gr
25
+ import gradio_client.utils as _gc_utils
26
  import pandas as pd
27
 
28
+ _orig_json_schema_to_python_type = _gc_utils._json_schema_to_python_type
29
+ def _patched_json_schema_to_python_type(schema, defs=None):
30
+ if not isinstance(schema, dict):
31
+ return "Any"
32
+ return _orig_json_schema_to_python_type(schema, defs)
33
+ _gc_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
34
+
35
  from evaluate_runner import DIFFICULTY_MULTIPLIER, DEFAULT_SERVER, compute_composite_score, compute_game_metrics
36
 
37
  logger = logging.getLogger(__name__)
 
1785
  return app
1786
 
1787
 
 
 
1788
  if __name__ == "__main__":
1789
  app = build_app()
1790
  app.launch(