diff options
-rw-r--r-- | uploader/phenotypes/views.py | 56 |
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( |