fix: patch gradio_client bool schema bug at source (tested locally — get_api_info passes)
Browse files- Dockerfile +14 -1
Dockerfile
CHANGED
|
@@ -8,7 +8,20 @@ RUN apt-get update && apt-get install -y \
|
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
COPY requirements.txt .
|
| 11 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
COPY . .
|
| 14 |
|
|
|
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
COPY requirements.txt .
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt && \
|
| 12 |
+
python3 -c "\
|
| 13 |
+
import pathlib; \
|
| 14 |
+
p = pathlib.Path('/usr/local/lib/python3.11/site-packages/gradio_client/utils.py'); \
|
| 15 |
+
src = p.read_text(); \
|
| 16 |
+
src = src.replace( \
|
| 17 |
+
'def get_type(schema: dict):\n if \"const\" in schema:', \
|
| 18 |
+
'def get_type(schema: dict):\n if not isinstance(schema, dict): return \"str\"\n if \"const\" in schema:'); \
|
| 19 |
+
src = src.replace( \
|
| 20 |
+
'def _json_schema_to_python_type(schema: Any, defs) -> str:\n \"\"\"Convert the json schema into a python type hint\"\"\"\n if schema == {}:', \
|
| 21 |
+
'def _json_schema_to_python_type(schema: Any, defs) -> str:\n \"\"\"Convert the json schema into a python type hint\"\"\"\n if isinstance(schema, bool): return \"Any\"\n if schema == {}:'); \
|
| 22 |
+
p.write_text(src); \
|
| 23 |
+
print('gradio_client patch applied') \
|
| 24 |
+
"
|
| 25 |
|
| 26 |
COPY . .
|
| 27 |
|