Monkey patch gradio to prevent it from calling home

This commit is contained in:
oobabooga 2023-04-18 01:13:16 -03:00 committed by GitHub
parent 6a810b16b2
commit 00186f76f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -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)

View File

@ -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