Spaces:
Running
Running
Commit ·
b5d447a
1
Parent(s): 9cc906d
gradio fix
Browse files
app.py
CHANGED
|
@@ -7,17 +7,17 @@ import time
|
|
| 7 |
import traceback
|
| 8 |
from validation import validate_json, validate_croissant, validate_records, validate_rai, generate_validation_report
|
| 9 |
|
| 10 |
-
# Patch gradio_client.utils
|
| 11 |
-
# gradio_client 1.7.2 crashes
|
| 12 |
-
#
|
| 13 |
-
#
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
def
|
| 17 |
if not isinstance(schema, dict):
|
| 18 |
return "any"
|
| 19 |
-
return
|
| 20 |
-
_gc_utils.
|
| 21 |
|
| 22 |
def process_file(file):
|
| 23 |
results = []
|
|
|
|
| 7 |
import traceback
|
| 8 |
from validation import validate_json, validate_croissant, validate_records, validate_rai, generate_validation_report
|
| 9 |
|
| 10 |
+
# Patch gradio_client.utils to handle boolean JSON schemas.
|
| 11 |
+
# gradio_client 1.7.2 crashes when a component schema has `additionalProperties: true/false`.
|
| 12 |
+
# The inner recursive function _json_schema_to_python_type receives True/False and either
|
| 13 |
+
# raises TypeError ("argument of type 'bool' is not iterable") or APIInfoParseError.
|
| 14 |
+
# Patching the inner function is the correct fix since it's called recursively.
|
| 15 |
+
_orig_json_schema_to_python_type = _gc_utils._json_schema_to_python_type
|
| 16 |
+
def _safe_json_schema_to_python_type(schema, defs=None):
|
| 17 |
if not isinstance(schema, dict):
|
| 18 |
return "any"
|
| 19 |
+
return _orig_json_schema_to_python_type(schema, defs)
|
| 20 |
+
_gc_utils._json_schema_to_python_type = _safe_json_schema_to_python_type
|
| 21 |
|
| 22 |
def process_file(file):
|
| 23 |
results = []
|