From f875926183e2e26881c3288e2f5c3d8ffe6397b8 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 22 Jan 2024 08:54:29 +0300 Subject: UI: Show progress of R/qtl2 bundle processing. --- qc_app/upload/rqtl2.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'qc_app/upload') diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index 7ba90c2..8a0d8b4 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -1,9 +1,9 @@ """Module to handle uploading of R/qtl2 bundles.""" import sys import json -from uuid import uuid4 from pathlib import Path from datetime import date +from uuid import UUID, uuid4 from zipfile import ZipFile, is_zipfile from redis import Redis @@ -581,4 +581,26 @@ def confirm_bundle_details(species_id: int, population_id: int): redisuri, f"{app.config['UPLOAD_FOLDER']}/job_errors") - raise NotImplementedError + return redirect(url_for("upload.rqtl2.rqtl2_processing_status", + jobid=jobid)) + +@rqtl2.route("/status/") +def rqtl2_processing_status(jobid: UUID): + """Retrieve the status of the job processing the uploaded R/qtl2 bundle.""" + with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn: + thejob = jobs.job(rconn, jobid) + if not bool(thejob): + return render_template("rqtl2/no-such-job.html", jobid=jobid) + + logmessages = rconn.lrange(thejob.get("log-messagelist"), 0, -1) or [] + + if thejob["status"] == "error": + return render_template( + "rqtl2/rqtl2-job-error.html", job=thejob, messages=logmessages) + if thejob["status"] == "success": + return render_template("rqtl2/rqtl2-job-results.html", + job=thejob, + messages=logmessages) + + return render_template( + "rqtl2/rqtl2-job-status.html", job=thejob, messages=logmessages) -- cgit v1.2.3