aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-12-02 15:51:39 -0600
committerFrederick Muriuki Muriithi2024-12-02 15:51:39 -0600
commit9914e9ed215e93bf1dea1f37d27c14150c3cad66 (patch)
treed4e2d251410713a8c86d9f13c5b6a37785c382f1
parent1b5de8142fface85eb6d2de4fdbff9a41536968a (diff)
downloadgn-uploader-9914e9ed215e93bf1dea1f37d27c14150c3cad66.tar.gz
Launch job and redirect to job status page.
-rw-r--r--uploader/phenotypes/views.py56
1 files changed, 37 insertions, 19 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index f23b377..b8c0e93 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -4,6 +4,7 @@ import uuid
import json
from pathlib import Path
from functools import wraps
+from logging import INFO, ERROR, DEBUG, FATAL, CRITICAL, WARNING
from redis import Redis
from requests.models import Response
@@ -347,25 +348,42 @@ def add_phenotypes(species: dict, population: dict, dataset: dict, **kwargs):# p
_jobid = uuid.uuid4()
_namespace = jobs.jobsnamespace()
_ttl_seconds = app.config["JOBS_TTL_SECONDS"]
- _job = jobs.initialise_job(
- rconn,
- _namespace,
- str(_jobid),
- [sys.executable, "-m", "scripts.rqtl2.phenotypes_qc", _sqluri,
- _redisuri, _namespace, str(_jobid), str(species["SpeciesId"]),
- str(population["Id"]), str(dataset["Id"]), "--redisexpiry",
- str(_ttl_seconds)], "phenotype_qc", _ttl_seconds,
- {"job-metadata": json.dumps({
- "speciesid": species["SpeciesId"],
- "populationid": population["Id"],
- "datasetid": dataset["Id"],
- "bundle": str(phenobundle.absolute())})})
- # jobs.launch_job(
- # _job,
- # redisuri,
- # f"{app.config['UPLOAD_FOLDER']}/job_errors")
-
- raise NotImplementedError("Please implement this...")
+ _job = jobs.launch_job(
+ jobs.initialise_job(
+ rconn,
+ _namespace,
+ str(_jobid),
+ [sys.executable, "-m", "scripts.rqtl2.phenotypes_qc", _sqluri,
+ _redisuri, _namespace, str(_jobid), str(species["SpeciesId"]),
+ str(population["Id"]),
+ # str(dataset["Id"]),
+ str(phenobundle),
+ "--loglevel",
+ {
+ INFO: "INFO",
+ ERROR: "ERROR",
+ DEBUG: "DEBUG",
+ FATAL: "FATAL",
+ CRITICAL: "CRITICAL",
+ WARNING: "WARNING"
+ }[app.logger.getEffectiveLevel()],
+ "--redisexpiry",
+ str(_ttl_seconds)], "phenotype_qc", _ttl_seconds,
+ {"job-metadata": json.dumps({
+ "speciesid": species["SpeciesId"],
+ "populationid": population["Id"],
+ "datasetid": dataset["Id"],
+ "bundle": str(phenobundle.absolute())})}),
+ _redisuri,
+ f"{app.config['UPLOAD_FOLDER']}/job_errors")
+
+ app.logger.debug("JOB DETAILS: %s", _job)
+
+ return redirect(url_for("species.populations.phenotypes.job_status",
+ species_id=species["SpeciesId"],
+ population_id=population["Id"],
+ dataset_id=dataset["Id"],
+ job_id=str(_job["jobid"])))
@phenotypesbp.route(