From 00186f76f4eb71666edd2facb43ce44af7d8b3c7 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 18 Apr 2023 01:13:16 -0300 Subject: [PATCH] Monkey patch gradio to prevent it from calling home --- modules/monkey_patch_gradio.py | 13 +++++++++++++ server.py | 1 + 2 files changed, 14 insertions(+) create mode 100644 modules/monkey_patch_gradio.py diff --git a/modules/monkey_patch_gradio.py b/modules/monkey_patch_gradio.py new file mode 100644 index 00000000..dcfc64e8 --- /dev/null +++ b/modules/monkey_patch_gradio.py @@ -0,0 +1,13 @@ +import importlib +import pathlib + +file_path = pathlib.Path(importlib.util.find_spec("gradio").submodule_search_locations[0]) / "strings.py" + +with open(file_path, 'r') as f: + contents = f.read() + +new_contents = contents.replace('threading.Thread(target=get_updated_messaging, args=(en,)).start()', '') +if contents != new_contents: + print('Patching gradio to prevent it from calling home every time it gets imported...') + with open(file_path, 'w') as f: + f.write(new_contents) diff --git a/server.py b/server.py index b7abf984..2a4f983d 100644 --- a/server.py +++ b/server.py @@ -4,6 +4,7 @@ import warnings os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False' os.environ['BITSANDBYTES_NOWELCOME'] = '1' warnings.filterwarnings('ignore', category=UserWarning, message='TypedStorage is deprecated') +from modules import monkey_patch_gradio import importlib import io