From dfb56175278409fc56298890b1ca617d0e00992c Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 2 Jun 2022 09:58:05 +0300 Subject: Add an error display to the progress status report Enable the progress status page to show all the errors found at any point during the processing of the file. --- qc_app/parse.py | 11 ++++++--- qc_app/templates/errors_display.html | 43 ++++++++++++++++++++++++++++++++++++ qc_app/templates/job_progress.html | 5 +++++ qc_app/templates/parse_results.html | 41 ++-------------------------------- 4 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 qc_app/templates/errors_display.html (limited to 'qc_app') diff --git a/qc_app/parse.py b/qc_app/parse.py index 578ab70..ec9962b 100644 --- a/qc_app/parse.py +++ b/qc_app/parse.py @@ -20,6 +20,7 @@ from quality_control.parsing import ( strain_names) parsebp = Blueprint("parse", __name__) +isinvalidvalue = lambda item: isinstance(item, InvalidValue) @parsebp.route("/parse", methods=["GET"]) def parse(): @@ -72,19 +73,23 @@ def parse_status(job_id: str): progress = float(job["percent"]) status = job["status"] filename = job.get("filename", "uploaded file") + errors = jsonpickle.decode( + job.get("errors", jsonpickle.encode(tuple()))) if status == "success": return redirect(url_for("parse.results", job_id=job_id)) if status == "parse-error": return redirect(url_for("parse.fail", job_id=job_id)) + app.jinja_env.globals.update(isinvalidvalue=isinvalidvalue) return render_template( "job_progress.html", job_id = job_id, job_status = status, progress = progress, message = job.get("message", ""), - job_name = f"Parsing '{filename}'") + job_name = f"Parsing '{filename}'", + errors=errors) return render_template("no_such_job.html", job_id=job_id) @@ -97,11 +102,11 @@ def results(job_id: str): if job: filename = job["filename"] errors = jsonpickle.decode(job["errors"]) + app.jinja_env.globals.update(isinvalidvalue=isinvalidvalue) return render_template( "parse_results.html", errors=errors, - job_name = f"Parsing '{filename}'", - isinvalidvalue=lambda item: isinstance(item, InvalidValue)) + job_name = f"Parsing '{filename}'") return render_template("no_such_job.html", job_id=job_id) diff --git a/qc_app/templates/errors_display.html b/qc_app/templates/errors_display.html new file mode 100644 index 0000000..0c9a212 --- /dev/null +++ b/qc_app/templates/errors_display.html @@ -0,0 +1,43 @@ +{%macro errors_display(errors, no_error_msg, error_message)%} + +{%if errors | length == 0 %} +{{no_error_msg}} +{%else %} +
{{error_message}}
+ +line number | +column(s) | +error | +error message | +
---|---|---|---|
{{error["line"]}} | ++ {%if isinvalidvalue(error):%} + {{error.column}} + {%else: %} + {{error.columns}} + {%endif %} + | ++ {%if isinvalidvalue(error):%} + Invalid Value + {%else: %} + Duplicate Header + {%endif %} + | +{{error["message"]}} | +
We found the following errors
- -line number | -column(s) | -error | -error message | -
---|---|---|---|
{{error["line"]}} | -- {%if isinvalidvalue(error):%} - {{error.column}} - {%else: %} - {{error.columns}} - {%endif %} - | -- {%if isinvalidvalue(error):%} - Invalid Value - {%else: %} - Duplicate Header - {%endif %} - | -{{error["message"]}} | -