JoaquinVanschoren commited on
Commit
9cc906d
·
1 Parent(s): 7893329

gradio fix

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,11 +1,24 @@
1
  import requests
2
  import os
3
  import gradio as gr
 
4
  import json
5
  import time
6
  import traceback
7
  from validation import validate_json, validate_croissant, validate_records, validate_rai, generate_validation_report
8
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def process_file(file):
10
  results = []
11
  json_data = None
@@ -626,4 +639,4 @@ def create_ui():
626
 
627
  if __name__ == "__main__":
628
  app = create_ui()
629
- app.launch(show_api=False)
 
1
  import requests
2
  import os
3
  import gradio as gr
4
+ import gradio_client.utils as _gc_utils
5
  import json
6
  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.get_type to handle boolean JSON schemas.
11
+ # gradio_client 1.7.2 crashes with "argument of type 'bool' is not iterable"
12
+ # when a component's JSON schema has `additionalProperties: true/false`.
13
+ # show_api=False in launch() doesn't remove the /info route in Gradio 5.20,
14
+ # so this patch is needed to prevent the crash on every request.
15
+ _orig_get_type = _gc_utils.get_type
16
+ def _safe_get_type(schema):
17
+ if not isinstance(schema, dict):
18
+ return "any"
19
+ return _orig_get_type(schema)
20
+ _gc_utils.get_type = _safe_get_type
21
+
22
  def process_file(file):
23
  results = []
24
  json_data = None
 
639
 
640
  if __name__ == "__main__":
641
  app = create_ui()
642
+ app.launch()