mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
updated PyPi version
This commit is contained in:
parent
f918fa0260
commit
0cd62350b5
@ -49,7 +49,8 @@ class Interface:
|
||||
capture_session=False, title=None, description=None,
|
||||
thumbnail=None, server_port=None, server_name=networking.LOCALHOST_NAME,
|
||||
allow_screenshot=True, allow_flagging=True,
|
||||
flagging_dir="flagged"):
|
||||
flagging_dir="flagged", analytics_enabled=True):
|
||||
|
||||
"""
|
||||
Parameters:
|
||||
fn (Callable): the function to wrap an interface around.
|
||||
@ -123,6 +124,7 @@ class Interface:
|
||||
self.allow_flagging = allow_flagging
|
||||
self.flagging_dir = flagging_dir
|
||||
Interface.instances.add(self)
|
||||
self.analytics_enabled=analytics_enabled
|
||||
|
||||
data = {'fn': fn,
|
||||
'inputs': inputs,
|
||||
@ -154,6 +156,7 @@ class Interface:
|
||||
self.flagging_dir = self.flagging_dir + "/" + dir_name + \
|
||||
"_{}".format(index)
|
||||
|
||||
if self.analytics_enabled:
|
||||
try:
|
||||
requests.post(analytics_url + 'gradio-initiated-analytics/',
|
||||
data=data)
|
||||
@ -293,6 +296,9 @@ class Interface:
|
||||
|
||||
is_colab = utils.colab_check()
|
||||
if not is_colab:
|
||||
if not networking.url_ok(path_to_local_server):
|
||||
share = True
|
||||
else:
|
||||
print(strings.en["RUNNING_LOCALLY"].format(path_to_local_server))
|
||||
else:
|
||||
if debug:
|
||||
@ -302,11 +308,19 @@ class Interface:
|
||||
print("Colab notebook detected. To show errors in colab notebook, set debug=True in launch()")
|
||||
|
||||
if share:
|
||||
print("This share link will expire in 6 hours. If you need a "
|
||||
"permanent link, email support@gradio.app")
|
||||
try:
|
||||
share_url = networking.setup_tunnel(server_port)
|
||||
print("Running on External URL:", share_url)
|
||||
except RuntimeError:
|
||||
utils.error_analytics("RuntimeError")
|
||||
data = {'error': 'RuntimeError in launch method'}
|
||||
if self.analytics_enabled:
|
||||
try:
|
||||
requests.post(analytics_url + 'gradio-error-analytics/',
|
||||
data=data)
|
||||
except requests.ConnectionError:
|
||||
pass # do not push analytics if no network
|
||||
share_url = None
|
||||
if self.verbose:
|
||||
print(strings.en["NGROK_NO_INTERNET"])
|
||||
@ -374,6 +388,8 @@ class Interface:
|
||||
'share_url': share_url,
|
||||
'ip_address': ip_address
|
||||
}
|
||||
|
||||
if self.analytics_enabled:
|
||||
try:
|
||||
requests.post(analytics_url + 'gradio-launched-analytics/',
|
||||
data=data)
|
||||
|
@ -16,7 +16,6 @@ import urllib.request
|
||||
from shutil import copyfile
|
||||
import requests
|
||||
import sys
|
||||
import analytics
|
||||
import csv
|
||||
|
||||
|
||||
@ -38,9 +37,6 @@ CONFIG_FILE = "static/config.json"
|
||||
ASSOCIATION_PATH_IN_STATIC = "static/apple-app-site-association"
|
||||
ASSOCIATION_PATH_IN_ROOT = "apple-app-site-association"
|
||||
|
||||
analytics.write_key = "uxIFddIEuuUcFLf9VgH2teTEtPlWdkNy"
|
||||
analytics_url = 'https://api.gradio.app/'
|
||||
|
||||
|
||||
def build_template(temp_dir):
|
||||
"""
|
||||
@ -128,21 +124,6 @@ def get_first_available_port(initial, final):
|
||||
)
|
||||
|
||||
|
||||
def send_prediction_analytics(interface):
|
||||
data = {'title': interface.title,
|
||||
'description': interface.description,
|
||||
'thumbnail': interface.thumbnail,
|
||||
'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
|
||||
|
||||
|
||||
def serve_files_in_background(interface, port, directory_to_serve=None, server_name=LOCALHOST_NAME):
|
||||
class HTTPHandler(SimpleHTTPRequestHandler):
|
||||
"""This handler uses server.base_path instead of always using os.getcwd()"""
|
||||
@ -174,10 +155,6 @@ def serve_files_in_background(interface, port, directory_to_serve=None, server_n
|
||||
output = {"data": prediction, "durations": durations}
|
||||
self.wfile.write(json.dumps(output).encode())
|
||||
|
||||
analytics_thread = threading.Thread(
|
||||
target=send_prediction_analytics, args=[interface])
|
||||
analytics_thread.start()
|
||||
|
||||
elif self.path == "/api/flag/":
|
||||
self._set_headers()
|
||||
data_string = self.rfile.read(
|
||||
|
@ -24,8 +24,7 @@ def colab_check():
|
||||
is_colab = False
|
||||
try: # Check if running interactively using ipython.
|
||||
from_ipynb = get_ipython()
|
||||
if "google.colab" in str(from_ipynb) or "ipykernel" in str(
|
||||
from_ipynb):
|
||||
if "google.colab" in str(from_ipynb):
|
||||
is_colab = True
|
||||
except NameError:
|
||||
error_analytics("NameError", analytics_url)
|
||||
|
@ -1,6 +1,6 @@
|
||||
Metadata-Version: 1.0
|
||||
Name: gradio
|
||||
Version: 1.1.5
|
||||
Version: 1.1.6
|
||||
Summary: Python library for easily interacting with trained machine learning models
|
||||
Home-page: https://github.com/gradio-app/gradio-UI
|
||||
Author: Abubakar Abid
|
||||
|
Loading…
Reference in New Issue
Block a user