From 6c1648b287d314b8684a98fdaf1cc9c0d82d63f9 Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Thu, 9 Jul 2020 15:15:34 -0500 Subject: [PATCH 1/3] fixed capture session code --- gradio/interface.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gradio/interface.py b/gradio/interface.py index ba0cda8667..4bcb2a009b 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -107,8 +107,16 @@ class Interface: '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: @@ -144,7 +152,6 @@ class Interface: return config - def process(self, raw_input): processed_input = [input_interface.preprocess( raw_input[i]) for i, input_interface in @@ -262,14 +269,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) From 08263b637ad1b1ffe5b5a1e41810aac9068e5018 Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Thu, 9 Jul 2020 15:16:18 -0500 Subject: [PATCH 2/3] updated PyPi version --- build/lib/gradio/interface.py | 31 +++++++++++++++---------------- gradio.egg-info/PKG-INFO | 2 +- setup.py | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/build/lib/gradio/interface.py b/build/lib/gradio/interface.py index 234745c0c5..4bcb2a009b 100644 --- a/build/lib/gradio/interface.py +++ b/build/lib/gradio/interface.py @@ -107,12 +107,20 @@ class Interface: '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 +152,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 +221,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 +237,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 +269,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 +290,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 +324,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"]) @@ -404,7 +403,7 @@ class Interface: 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..9c6fd93c7b 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.8 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/setup.py b/setup.py index 4bd0ce9e63..813749c037 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.8', include_package_data=True, description='Python library for easily interacting with trained machine learning models', author='Abubakar Abid', From fccee94b680062c5c447817ad8df203ab6da363f Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Thu, 9 Jul 2020 15:22:18 -0500 Subject: [PATCH 3/3] updated PyPi version --- build/lib/gradio/interface.py | 4 ---- gradio.egg-info/PKG-INFO | 2 +- setup.py | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/build/lib/gradio/interface.py b/build/lib/gradio/interface.py index 4bcb2a009b..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,7 +102,6 @@ class Interface: 'saliency': saliency, 'live': live, 'capture_session': capture_session, - 'host_name': hostname, 'ip_address': ip_address } @@ -396,7 +393,6 @@ class Interface: 'is_google_colab': is_colab, 'is_sharing_on': share, 'share_url': share_url, - 'host_name': hostname, 'ip_address': ip_address } try: diff --git a/gradio.egg-info/PKG-INFO b/gradio.egg-info/PKG-INFO index 9c6fd93c7b..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.8 +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/setup.py b/setup.py index 813749c037..7e158ca572 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ except ImportError: setup( name='gradio', - version='0.9.9.8', + version='0.9.9.9', include_package_data=True, description='Python library for easily interacting with trained machine learning models', author='Abubakar Abid',