aboutsummaryrefslogtreecommitdiff
path: root/qc_app/parse.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-06-15 09:36:18 +0300
committerFrederick Muriuki Muriithi2022-06-15 09:36:18 +0300
commitd2605cb72d7cdbc7d3cc633b94a451c0acd2edbb (patch)
tree8bf992967a750bf4dc71290b78285f6239823816 /qc_app/parse.py
parent6760d322637a3d875242a66e9c1a784866d7df1d (diff)
downloadgn-uploader-d2605cb72d7cdbc7d3cc633b94a451c0acd2edbb.tar.gz
Fix linting and type errors
Diffstat (limited to 'qc_app/parse.py')
-rw-r--r--qc_app/parse.py21
1 files changed, 6 insertions, 15 deletions
diff --git a/qc_app/parse.py b/qc_app/parse.py
index b2a0156..e72a163 100644
--- a/qc_app/parse.py
+++ b/qc_app/parse.py
@@ -1,23 +1,13 @@
"""File parsing module"""
import os
-from functools import reduce
import jsonpickle
from redis import Redis
-from flask import (
- flash,
- request,
- url_for,
- redirect,
- Blueprint,
- render_template,
- current_app as app)
+from flask import flash, request, url_for, redirect, Blueprint, render_template
+from flask import current_app as app
-from . import jobs
from quality_control.errors import InvalidValue
-from quality_control.parsing import (
- FileType,
- strain_names)
+from . import jobs
parsebp = Blueprint("parse", __name__)
isinvalidvalue = lambda item: isinstance(item, InvalidValue)
@@ -25,7 +15,6 @@ isinvalidvalue = lambda item: isinstance(item, InvalidValue)
@parsebp.route("/parse", methods=["GET"])
def parse():
"""Trigger file parsing"""
- # TODO: Maybe implement external process to parse the files
errors = False
filename = request.args.get("filename")
filetype = request.args.get("filetype")
@@ -59,6 +48,7 @@ def parse():
@parsebp.route("/status/<job_id>", methods=["GET"])
def parse_status(job_id: str):
+ "Retrieve the status of the job"
with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn:
job = jobs.job(rconn, job_id)
@@ -76,7 +66,7 @@ def parse_status(job_id: str):
filename = job.get("filename", "uploaded file")
errors = jsonpickle.decode(
job.get("errors", jsonpickle.encode(tuple())))
- if status == "success" or status == "aborted":
+ if status in ("success", "aborted"):
return redirect(url_for("parse.results", job_id=job_id))
if status == "parse-error":
@@ -133,6 +123,7 @@ def fail(job_id: str):
@parsebp.route("/abort", methods=["POST"])
def abort():
+ """Handle user request to abort file processing"""
job_id = request.form["job_id"]
with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn: