diff --git a/build/lib/gradio/interface.py b/build/lib/gradio/interface.py index 234745c0c5..6d7177f520 100644 --- a/build/lib/gradio/interface.py +++ b/build/lib/gradio/interface.py @@ -20,13 +20,11 @@ from IPython import get_ipython import sys import weakref import analytics -import socket PKG_VERSION_URL = "https://gradio.app/api/pkg-version" analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy" analytics_url = 'https://api.gradio.app/' -hostname = socket.gethostname() try: ip_address = requests.get('https://api.ipify.org').text except requests.ConnectionError: @@ -104,15 +102,22 @@ class Interface: 'saliency': saliency, 'live': live, 'capture_session': capture_session, - 'host_name': hostname, 'ip_address': ip_address } + + if self.capture_session: + try: + import tensorflow as tf + self.session = tf.get_default_graph(), \ + tf.keras.backend.get_session() + except (ImportError, AttributeError): # If they are using TF >= 2.0 or don't have TF, just ignore this. + pass + try: - print("try initiated") requests.post(analytics_url + 'gradio-initiated-analytics/', data=data) except requests.ConnectionError: - print("gradio-initiated-analytics/ Connection Error") + pass # do not push analytics if no network def get_config_file(self): config = { @@ -144,7 +149,6 @@ class Interface: return config - def process(self, raw_input): processed_input = [input_interface.preprocess( raw_input[i]) for i, input_interface in @@ -214,7 +218,7 @@ class Interface: requests.post(analytics_url + 'gradio-error-analytics/', data=data) except requests.ConnectionError: - print("gradio-error-analytics/ Connection Error") + pass # do not push analytics if no network if self.verbose: print("\n----------") print( @@ -230,7 +234,7 @@ class Interface: requests.post(analytics_url + 'gradio-error-analytics/', data=data) except requests.ConnectionError: - print("gradio-error-analytics/ Connection Error") + pass # do not push analytics if no network if self.verbose: print("\n----------") print( @@ -262,14 +266,6 @@ class Interface: # if validate and not self.validate_flag: # self.validate() - if self.capture_session: - try: - import tensorflow as tf - self.session = tf.get_default_graph(), \ - tf.keras.backend.get_session() - except (ImportError, AttributeError): # If they are using TF >= 2.0 or don't have TF, just ignore this. - pass - output_directory = tempfile.mkdtemp() # Set up a port to serve the directory containing the static files with interface. server_port, httpd = networking.start_simple_server(self, output_directory, self.server_name) @@ -291,7 +287,7 @@ class Interface: requests.post(analytics_url + 'gradio-error-analytics/', data=data) except requests.ConnectionError: - print("Connection Error") + pass # do not push analytics if no network pass try: @@ -325,7 +321,7 @@ class Interface: requests.post(analytics_url + 'gradio-error-analytics/', data=data) except requests.ConnectionError: - print("Connection Error") + pass # do not push analytics if no network share_url = None if self.verbose: print(strings.en["NGROK_NO_INTERNET"]) @@ -397,14 +393,13 @@ class Interface: 'is_google_colab': is_colab, 'is_sharing_on': share, 'share_url': share_url, - 'host_name': hostname, 'ip_address': ip_address } try: requests.post(analytics_url + 'gradio-launched-analytics/', data=data) except requests.ConnectionError: - print("Connection Error") + pass # do not push analytics if no network return httpd, path_to_local_server, share_url @classmethod diff --git a/gradio.egg-info/PKG-INFO b/gradio.egg-info/PKG-INFO index dd45446322..07da4ec1f1 100644 --- a/gradio.egg-info/PKG-INFO +++ b/gradio.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: gradio -Version: 0.9.9.7 +Version: 0.9.9.9 Summary: Python library for easily interacting with trained machine learning models Home-page: https://github.com/gradio-app/gradio-UI Author: Abubakar Abid diff --git a/gradio/interface.py b/gradio/interface.py index 61ee01509e..d8ed3ae0c3 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -20,13 +20,11 @@ from IPython import get_ipython import sys import weakref import analytics -import socket PKG_VERSION_URL = "https://gradio.app/api/pkg-version" analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy" analytics_url = 'https://api.gradio.app/' -hostname = socket.gethostname() try: ip_address = requests.get('https://api.ipify.org').text except requests.ConnectionError: @@ -104,15 +102,22 @@ class Interface: 'saliency': saliency, 'live': live, 'capture_session': capture_session, - 'host_name': hostname, 'ip_address': ip_address } + + if self.capture_session: + try: + import tensorflow as tf + self.session = tf.get_default_graph(), \ + tf.keras.backend.get_session() + except (ImportError, AttributeError): # If they are using TF >= 2.0 or don't have TF, just ignore this. + pass + try: - print("try initiated") requests.post(analytics_url + 'gradio-initiated-analytics/', data=data) except requests.ConnectionError: - print("gradio-initiated-analytics/ Connection Error") + pass # do not push analytics if no network def get_config_file(self): config = { @@ -144,7 +149,6 @@ class Interface: return config - def process(self, raw_input): processed_input = [input_interface.preprocess( raw_input[i]) for i, input_interface in @@ -214,7 +218,7 @@ class Interface: requests.post(analytics_url + 'gradio-error-analytics/', data=data) except requests.ConnectionError: - print("gradio-error-analytics/ Connection Error") + pass # do not push analytics if no network if self.verbose: print("\n----------") print( @@ -230,7 +234,7 @@ class Interface: requests.post(analytics_url + 'gradio-error-analytics/', data=data) except requests.ConnectionError: - print("gradio-error-analytics/ Connection Error") + pass # do not push analytics if no network if self.verbose: print("\n----------") print( @@ -262,14 +266,6 @@ class Interface: # if validate and not self.validate_flag: # self.validate() - if self.capture_session: - try: - import tensorflow as tf - self.session = tf.get_default_graph(), \ - tf.keras.backend.get_session() - except (ImportError, AttributeError): # If they are using TF >= 2.0 or don't have TF, just ignore this. - pass - output_directory = tempfile.mkdtemp() # Set up a port to serve the directory containing the static files with interface. server_port, httpd = networking.start_simple_server(self, output_directory, self.server_name) @@ -291,7 +287,7 @@ class Interface: requests.post(analytics_url + 'gradio-error-analytics/', data=data) except requests.ConnectionError: - print("Connection Error") + pass # do not push analytics if no network pass try: @@ -325,7 +321,7 @@ class Interface: requests.post(analytics_url + 'gradio-error-analytics/', data=data) except requests.ConnectionError: - print("Connection Error") + pass # do not push analytics if no network share_url = None if self.verbose: print(strings.en["NGROK_NO_INTERNET"]) @@ -398,14 +394,13 @@ class Interface: 'is_google_colab': is_colab, 'is_sharing_on': share, 'share_url': share_url, - 'host_name': hostname, 'ip_address': ip_address } try: requests.post(analytics_url + 'gradio-launched-analytics/', data=data) except requests.ConnectionError: - print("Connection Error") + pass # do not push analytics if no network return httpd, path_to_local_server, share_url @classmethod diff --git a/gradio/networking.py b/gradio/networking.py index 5d0853e4c8..6eaf8c25b7 100644 --- a/gradio/networking.py +++ b/gradio/networking.py @@ -15,6 +15,7 @@ import urllib.request from shutil import copyfile import requests import sys +import analytics INITIAL_PORT_VALUE = ( @@ -38,6 +39,8 @@ ASSOCIATION_PATH_IN_ROOT = "apple-app-site-association" FLAGGING_DIRECTORY = 'static/flagged/' FLAGGING_FILENAME = 'data.txt' +analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy" +analytics_url = 'https://api.gradio.app/' def build_template(temp_dir): @@ -159,6 +162,15 @@ def serve_files_in_background(interface, port, directory_to_serve=None, server_n # Prepare return json dictionary. self.wfile.write(json.dumps(output).encode()) + data = {'input_interface': interface.input_interfaces, + 'output_interface': interface.output_interfaces, + } + try: + requests.post( + analytics_url + 'gradio-prediction-analytics/', + data=data) + except requests.ConnectionError: + pass # do not push analytics if no network elif self.path == "/api/flag/": self._set_headers() diff --git a/setup.py b/setup.py index 4bd0ce9e63..7e158ca572 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ except ImportError: setup( name='gradio', - version='0.9.9.7', + version='0.9.9.9', include_package_data=True, description='Python library for easily interacting with trained machine learning models', author='Abubakar Abid',