Re-apply schema-walker monkey-patch
Browse files5 unmodified lines67891011125 unmodified linesthe Space so the demo works offline of the laptop."""from __future__ import annotationsimport jsonfrom pathlib import Path5 unmodified lines6789101112131415161718192021222324252627282930313233343536373839405 unmodified linesthe Space so the demo works offline of the laptop."""# ----------------------------------------------------------------------# Monkey-patch gradio_client schema walker BEFORE importing gradio.# Newer gradio_client (auto-installed by pip's resolution of gradio>=4.44)# crashes at startup with `TypeError: argument of type 'bool' is not# iterable` when it walks a schema with `additionalProperties: True`# (which gr.JSON outputs produce). This brings the / route down and# launch() then errors with "localhost is not accessible". Returning# "Any" for bool schemas is what the unbroken upstream code does.# ----------------------------------------------------------------------import gradio_client.utils as _gc_utils # noqa: E402_orig_get_type = _gc_utils.get_type_orig_to_python = _gc_utils._json_schema_to_python_typedef _safe_get_type(schema):if isinstance(schema, bool):return "Any" if schema else "None"return _orig_get_type(schema)def _safe_to_python(schema, defs):if isinstance(schema, bool):return "Any" if schema else "None"return _orig_to_python(schema, defs)_gc_utils.get_type = _safe_get_type_gc_utils._json_schema_to_python_type = _safe_to_pythonimport jsonfrom pathlib import Path
app.py+29-1