From 45f7328e733fa655e7871d3c841c2dc778915d36 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 31 May 2022 14:39:31 +0300 Subject: Fix error rendering Render the command_id if present in the error report to help with troubleshooting failures. --- wqflask/wqflask/partial_correlations_views.py | 17 +++++++++++++---- .../templates/partial_correlations/pcorrs_error.html | 8 ++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/wqflask/wqflask/partial_correlations_views.py b/wqflask/wqflask/partial_correlations_views.py index 7456ae2e..ce5e46e0 100644 --- a/wqflask/wqflask/partial_correlations_views.py +++ b/wqflask/wqflask/partial_correlations_views.py @@ -224,10 +224,11 @@ def response_error_message(response): response.status_code, "General API server error!!") -def render_error(error_message): +def render_error(error_message, command_id = None): return render_template( "partial_correlations/pcorrs_error.html", - message = error_message) + message = error_message, + command_id = command_id) def __format_number(num): if num is None or math.isnan(num): @@ -346,10 +347,18 @@ def process_pcorrs_command_output(result): def poll_partial_correlation_results(command_id): response = requests.get( url=f"{GN_SERVER_URL}api/async_commands/state/{command_id}") + if response.status_code == 200: data = response.json() - if data["status"] == "error": - return render_error(response["result"]) + raw_result = data["result"] + result = {"status": "computing"} + if raw_result: + result = json.loads(raw_result) + if result["status"].lower() in ("error", "exception"): + return render_error( + "We messed up, and the computation failed due to a system " + "error.", + command_id) if data["status"] == "success": return process_pcorrs_command_output(json.loads(data["result"])) return render_template( diff --git a/wqflask/wqflask/templates/partial_correlations/pcorrs_error.html b/wqflask/wqflask/templates/partial_correlations/pcorrs_error.html index 91f6baf2..8d6c4bbe 100644 --- a/wqflask/wqflask/templates/partial_correlations/pcorrs_error.html +++ b/wqflask/wqflask/templates/partial_correlations/pcorrs_error.html @@ -36,6 +36,14 @@ {{message}}

+ {%if command_id %} +

+ Please provide the following information to help with + troubleshooting:
+ Command ID: {{command_id}} +

+ {%endif%} +

To check if this already a known issue, search the issue -- cgit v1.2.3