xinjie.wang
update
7c8cbf6
# Project EmbodiedGen
#
# Copyright (c) 2025 Horizon Robotics. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
import fileinput
import site
import gradio_client.utils as gradio_client_utils
def _patch_gradio_schema_bool_bug() -> None:
"""Patch schema parser for bool-style for gradio<5.33."""
original_get_type = gradio_client_utils.get_type
original_json_schema_to_python_type = (
gradio_client_utils._json_schema_to_python_type
)
def _safe_get_type(schema):
if isinstance(schema, bool):
return {}
return original_get_type(schema)
def _safe_json_schema_to_python_type(schema, defs):
if isinstance(schema, bool):
return "Any"
return original_json_schema_to_python_type(schema, defs)
gradio_client_utils.get_type = _safe_get_type
gradio_client_utils._json_schema_to_python_type = (
_safe_json_schema_to_python_type
)
def _patch_open3d_cuda_device_count_bug() -> None:
"""Patch open3d to avoid cuda device count bug."""
with fileinput.FileInput(
f'{site.getsitepackages()[0]}/open3d/__init__.py', inplace=True
) as file:
for line in file:
print(
line.replace(
'_pybind_cuda.open3d_core_cuda_device_count()', '1'
),
end='',
)