Spaces:
Running
Running
Ziyang Wang commited on
Commit ·
7b3d33e
1
Parent(s): 9861d7d
monkey-patch gradio_client.utils.get_type to handle bool schemas
Browse files
app.py
CHANGED
|
@@ -9,6 +9,19 @@ Tabs:
|
|
| 9 |
|
| 10 |
import os
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
import gradio as gr
|
| 13 |
import pandas as pd
|
| 14 |
|
|
|
|
| 9 |
|
| 10 |
import os
|
| 11 |
|
| 12 |
+
# Workaround for a long-standing gradio_client bug that hits the /info endpoint
|
| 13 |
+
# when any component emits a JSON schema with `additionalProperties: True/False`
|
| 14 |
+
# (a plain bool). get_type() does `if "const" in schema:` which raises
|
| 15 |
+
# `TypeError: argument of type 'bool' is not iterable`. Patch it before Gradio
|
| 16 |
+
# loads the FastAPI routes.
|
| 17 |
+
import gradio_client.utils as _gcu
|
| 18 |
+
_orig_get_type = _gcu.get_type
|
| 19 |
+
def _safe_get_type(schema):
|
| 20 |
+
if not isinstance(schema, dict):
|
| 21 |
+
return "Any"
|
| 22 |
+
return _orig_get_type(schema)
|
| 23 |
+
_gcu.get_type = _safe_get_type
|
| 24 |
+
|
| 25 |
import gradio as gr
|
| 26 |
import pandas as pd
|
| 27 |
|