codemichaeld commited on
Commit
cd0640f
·
verified ·
1 Parent(s): b3d1ee3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -11
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import os
3
  import sys
4
  import json
@@ -16,19 +15,55 @@ if "COMFY_ALLOW_VENDORED" not in os.environ:
16
  os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "0")
17
  os.environ.setdefault("TOKENIZERS_PARALLELISM", "false")
18
 
19
- try:
20
- import gradio_client.utils as _gc_utils
21
- _orig_get_type = getattr(_gc_utils, "get_type", None)
22
- if _orig_get_type is not None and not getattr(_orig_get_type, "_w4a8_patched", False):
23
- def _safe_get_type(schema):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  if not isinstance(schema, dict):
25
  return "any"
26
- return _orig_get_type(schema)
27
- _safe_get_type._w4a8_patched = True
28
- _gc_utils.get_type = _safe_get_type
29
- print("[main] gradio_client.get_type patched for boolean additionalProperties")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  except Exception as _e:
31
- print("[main] gradio_client patch skipped:", _e)
 
32
 
33
  try:
34
  from install_w4a8 import install as _install_w4a8
 
 
1
  import os
2
  import sys
3
  import json
 
15
  os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "0")
16
  os.environ.setdefault("TOKENIZERS_PARALLELISM", "false")
17
 
18
+
19
+ def _patch_gradio_client():
20
+ import gradio_client.utils as gu
21
+
22
+ patched_any = False
23
+
24
+ orig_get_type = getattr(gu, "get_type", None)
25
+ if orig_get_type is not None and not getattr(orig_get_type, "_w4a8_patched", False):
26
+ def safe_get_type(schema):
27
+ if not isinstance(schema, dict):
28
+ return "any"
29
+ return orig_get_type(schema)
30
+ safe_get_type._w4a8_patched = True
31
+ gu.get_type = safe_get_type
32
+ patched_any = True
33
+
34
+ orig_jstp = getattr(gu, "_json_schema_to_python_type", None)
35
+ if orig_jstp is not None and not getattr(orig_jstp, "_w4a8_patched", False):
36
+ def safe_jstp(schema, defs=None):
37
  if not isinstance(schema, dict):
38
  return "any"
39
+ return orig_jstp(schema, defs)
40
+ safe_jstp._w4a8_patched = True
41
+ gu._json_schema_to_python_type = safe_jstp
42
+ patched_any = True
43
+
44
+ orig_public = getattr(gu, "json_schema_to_python_type", None)
45
+ if orig_public is not None and not getattr(orig_public, "_w4a8_patched", False):
46
+ def safe_public(schema, defs=None):
47
+ if not isinstance(schema, dict):
48
+ return "any"
49
+ try:
50
+ return orig_public(schema, defs)
51
+ except TypeError:
52
+ return "any"
53
+ safe_public._w4a8_patched = True
54
+ gu.json_schema_to_python_type = safe_public
55
+ patched_any = True
56
+
57
+ return patched_any
58
+
59
+
60
+ try:
61
+ _ok = _patch_gradio_client()
62
+ sys.stderr.write(f"[main] gradio_client patch applied={_ok}\n")
63
+ sys.stderr.flush()
64
  except Exception as _e:
65
+ sys.stderr.write(f"[main] gradio_client patch FAILED: {type(_e).__name__}: {_e}\n")
66
+ sys.stderr.flush()
67
 
68
  try:
69
  from install_w4a8 import install as _install_w4a8