diff options
author | Frederick Muriuki Muriithi | 2024-01-20 09:57:23 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-01-20 09:57:23 +0300 |
commit | cdd4dc456e56bb4eb055e1cb7f2518d45fb3bfb9 (patch) | |
tree | 73248acbadd5014f2b26da41da3098f1ac5ecc1e /qc_app/parse.py | |
parent | 53b1e7cb181380a24aab4cbc7a9634b2d8dd2d29 (diff) | |
download | gn-uploader-cdd4dc456e56bb4eb055e1cb7f2518d45fb3bfb9.tar.gz |
Fetch sample/case names from database
Fetch the sample/case names from the database rather than from a
static file in the repository.
Issue:
https://issues.genenetwork.org/issues/quality-control/read-samples-from-database-by-species
Diffstat (limited to 'qc_app/parse.py')
-rw-r--r-- | qc_app/parse.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/qc_app/parse.py b/qc_app/parse.py index ceb8fcf..40f7b44 100644 --- a/qc_app/parse.py +++ b/qc_app/parse.py @@ -7,7 +7,10 @@ from flask import flash, request, url_for, redirect, Blueprint, render_template from flask import current_app as app from quality_control.errors import InvalidValue, DuplicateHeading -from . import jobs + +from qc_app import jobs +from qc_app.dbinsert import species_by_id +from qc_app.db_utils import with_db_connection parsebp = Blueprint("parse", __name__) @@ -23,8 +26,25 @@ def isduplicateheading(item): def parse(): """Trigger file parsing""" errors = False + speciesid = request.args.get("speciesid") filename = request.args.get("filename") filetype = request.args.get("filetype") + if speciesid is None: + flash("No species selected", "alert-error") + errors = True + else: + try: + speciesid = int(speciesid) + species = with_db_connection( + lambda con: species_by_id(con, speciesid)) + if not bool(species): + flash("No such species.", "alert-error") + errors = True + except ValueError: + flash("Invalid speciesid provided. Expected an integer.", + "alert-error") + errors = True + if filename is None: flash("No file provided", "alert-error") errors = True @@ -50,7 +70,8 @@ def parse(): with Redis.from_url(redisurl, decode_responses=True) as rconn: job = jobs.launch_job( jobs.build_file_verification_job( - rconn, filepath, filetype, redisurl, + rconn, app.config["SQL_URI"], redisurl, + speciesid, filepath, filetype, app.config["JOBS_TTL_SECONDS"]), redisurl, f"{app.config['UPLOAD_FOLDER']}/job_errors") |