From c58c1d89bdbd303d969b8156a3effe355138fa16 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 18 Apr 2023 03:56:20 -0300 Subject: [PATCH] Clean method to prevent gradio from phoning home --- server.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 310d49b..7556132 100644 --- a/server.py +++ b/server.py @@ -1,10 +1,21 @@ import os +import requests 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 dirty_patch_gradio + +# This is a hack to prevent Gradio from phoning home when it gets imported +def my_get(url, **kwargs): + print('Gradio HTTP request redirected to localhost :)') + kwargs.setdefault('allow_redirects', True) + return requests.api.request('get', 'http://127.0.0.1/', **kwargs) + +original_get = requests.get +requests.get = my_get +import gradio as gr +requests.get = original_get import importlib import io @@ -19,7 +30,6 @@ import zipfile from datetime import datetime from pathlib import Path -import gradio as gr import psutil import torch import yaml