From e0e73c95b50cf1b6cf3a537df96a1e0c5868fa14 Mon Sep 17 00:00:00 2001 From: dawoodkhan82 Date: Mon, 18 Oct 2021 14:20:06 -0400 Subject: [PATCH 1/2] log error code --- gradio/networking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradio/networking.py b/gradio/networking.py index 08cb687c6a..b42185141a 100644 --- a/gradio/networking.py +++ b/gradio/networking.py @@ -184,7 +184,7 @@ def predict(): prediction, durations = app.interface.process(raw_input) except BaseException as error: traceback.print_exc() - return jsonify({"error": traceback.format_exc()}) + return jsonify({"error": traceback.format_exc()}), 500 else: prediction, durations = app.interface.process(raw_input) # Get running average of prediction times From 67037adcbad3ea67a59cd8d1005cfd49eb96c24a Mon Sep 17 00:00:00 2001 From: dawoodkhan82 Date: Mon, 18 Oct 2021 14:50:28 -0400 Subject: [PATCH 2/2] add show_error flag --- gradio/interface.py | 6 +++++- gradio/networking.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gradio/interface.py b/gradio/interface.py index 279d6dc917..852526098d 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -478,7 +478,9 @@ class Interface: print("PASSED") continue - def launch(self, inline=None, inbrowser=None, share=False, debug=False, auth=None, auth_message=None, private_endpoint=None, prevent_thread_lock=False): + def launch(self, inline=None, inbrowser=None, share=False, debug=False, + auth=None, auth_message=None, private_endpoint=None, + prevent_thread_lock=False, show_error=True): """ Launches the webserver that serves the UI for the interface. Parameters: @@ -492,6 +494,7 @@ class Interface: app (flask.Flask): Flask app object path_to_local_server (str): Locally accessible link share_url (str): Publicly accessible link (if share=True) + show_error (bool): show prediction errors in console """ # Alert user if a more recent version of the library exists utils.version_check() @@ -516,6 +519,7 @@ class Interface: self.server_port = server_port self.status = "RUNNING" self.server = app + self.show_error = show_error # Count number of launches launch_counter() diff --git a/gradio/networking.py b/gradio/networking.py index b42185141a..2472a97053 100644 --- a/gradio/networking.py +++ b/gradio/networking.py @@ -179,7 +179,7 @@ def enable_sharing(path): def predict(): raw_input = request.json["data"] # If in debug mode, capture any errors made and pipe to front end - if app.interface.debug: + if app.interface.show_error: try: prediction, durations = app.interface.process(raw_input) except BaseException as error: