aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-24 10:22:09 +0300
committerFrederick Muriuki Muriithi2024-01-24 10:22:09 +0300
commit60e6fe7fbba0f83da5d793d7ab55ff3f873fe42a (patch)
tree2cf672f021afc33d775e83da219e5854aae9728b /qc_app
parent7976230ffcb1de4f744895ee252298dea9a15f4c (diff)
downloadgn-uploader-60e6fe7fbba0f83da5d793d7ab55ff3f873fe42a.tar.gz
redis-prefix: Update file validation code
Update the file validation script and routes to use the redis prefix for jobs.
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/jobs.py9
-rw-r--r--qc_app/parse.py12
2 files changed, 13 insertions, 8 deletions
diff --git a/qc_app/jobs.py b/qc_app/jobs.py
index cf4e4ef..1491015 100644
--- a/qc_app/jobs.py
+++ b/qc_app/jobs.py
@@ -62,12 +62,13 @@ def build_file_verification_job(#pylint: disable=[too-many-arguments]
jobid = str(uuid4())
command = [
sys.executable, "-m", "scripts.validate_file",
- dburi, redisuri, jobid,
+ dburi, redisuri, jobsnamespace(), jobid,
"--redisexpiry", str(ttl_seconds),
str(speciesid), filetype, filepath,
]
return initialise_job(
- redis_conn, jobid, command, "file-verification", ttl_seconds, {
+ redis_conn, jobsnamespace(), jobid, command, "file-verification",
+ ttl_seconds, {
"filetype": filetype,
"filename": os.path.basename(filepath), "percent": 0
})
@@ -77,12 +78,14 @@ def data_insertion_job(# pylint: disable=[too-many-arguments]
speciesid: int, platformid: int, datasetid: int, databaseuri: str,
redisuri: str, ttl_seconds: int) -> dict:
"Build a data insertion job"
+ jobid = str(uuid4())
command = [
sys.executable, "-m", "scripts.insert_data", filetype, filepath,
speciesid, platformid, datasetid, databaseuri, redisuri
]
return initialise_job(
- redis_conn, str(uuid4()), command, "data-insertion", ttl_seconds, {
+ redis_conn, jobsnamespace(), jobid, command, "data-insertion",
+ ttl_seconds, {
"filename": os.path.basename(filepath), "filetype": filetype,
"totallines": totallines
})
diff --git a/qc_app/parse.py b/qc_app/parse.py
index 40f7b44..d9be993 100644
--- a/qc_app/parse.py
+++ b/qc_app/parse.py
@@ -82,7 +82,7 @@ def parse():
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)
+ job = jobs.job(rconn, jobs.jobsnamespace(), job_id)
if job:
error_filename = jobs.error_filename(
@@ -122,7 +122,7 @@ def parse_status(job_id: str):
def results(job_id: str):
"""Show results of parsing..."""
with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn:
- job = jobs.job(rconn, job_id)
+ job = jobs.job(rconn, jobs.jobsnamespace(), job_id)
if job:
filename = job["filename"]
@@ -143,7 +143,7 @@ def results(job_id: str):
def fail(job_id: str):
"""Handle parsing failure"""
with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn:
- job = jobs.job(rconn, job_id)
+ job = jobs.job(rconn, jobs.jobsnamespace(), job_id)
if job:
error_filename = jobs.error_filename(
@@ -164,9 +164,11 @@ def abort():
job_id = request.form["job_id"]
with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn:
- job = jobs.job(rconn, job_id)
+ job = jobs.job(rconn, jobs.jobsnamespace(), job_id)
if job:
- rconn.hset(name=job_id, key="user_aborted", value=int(True))
+ rconn.hset(name=jobs.job_key(jobs.jobsnamespace(), job_id),
+ key="user_aborted",
+ value=int(True))
return redirect(url_for("parse.parse_status", job_id=job_id))