def pipeline(): """POST a pipeline job (JSON) to run on the Luigi pipeline.""" if not request.data: return 'POST a JSON pipeline config to execute or an id to GET. Body should be pipeline JSON' try: init() p_cfg = PipelineConfig.from_dict(request.get_json()) p_id = insert_pipeline_config(p_cfg, util.conn_string) if p_id == -1: return '{ "success", false }' job_id = jobs.create_new_job(jobs.NlpJob(job_id=-1, name=p_cfg.name, description=p_cfg.description, owner=p_cfg.owner, status=jobs.STARTED, date_ended=None, phenotype_id=-1, pipeline_id=p_id, date_started=datetime.now(), job_type='PIPELINE'), util.conn_string) luigi_runner.run_pipeline( p_cfg.config_type, str(p_id), job_id, p_cfg.owner) output = dict() output["pipeline_id"] = str(p_id) output["job_id"] = str(job_id) output["luigi_task_monitoring"] = "%s/static/visualiser/index.html#search__search=job=%s" % ( util.luigi_url, str(job_id)) output["status_endpoint"] = "%s/status/%s" % ( util.main_url, str(job_id)) output["results_endpoint"] = "%s/job_results/%s/%s" % ( util.main_url, str(job_id), 'pipeline') return json.dumps(output, indent=4) except Exception as ex: return 'Failed to load and insert pipeline. ' + str(ex), 400
def pipeline(): """POST a pipeline job (JSON) to run on the Luigi pipeline.""" if not request.data: return 'POST a JSON pipeline config to execute or an id to GET. Body should be pipeline JSON' try: init() p_cfg = PipelineConfig.from_dict(request.get_json()) p_id = insert_pipeline_config(p_cfg, util.conn_string) if p_id == -1: return '{ "success", false }' job_id = jobs.create_new_job(jobs.NlpJob(job_id=-1, name=p_cfg.name, description=p_cfg.description, owner=p_cfg.owner, status=jobs.STARTED, date_ended=None, phenotype_id=-1, pipeline_id=p_id, date_started=datetime.now(), job_type='PIPELINE'), util.conn_string) luigi_runner.run_pipeline(p_cfg.config_type, str(p_id), job_id, p_cfg.owner) output = dict() output["pipeline_id"] = str(p_id) output["job_id"] = str(job_id) output["luigi_task_monitoring"] = "%s/static/visualiser/index.html#search__search=job=%s" % ( util.luigi_url, str(job_id)) output["status_endpoint"] = "%s/status/%s" % (util.main_url, str(job_id)) output["results_endpoint"] = "%s/job_results/%s/%s" % (util.main_url, str(job_id), 'pipeline') return json.dumps(output, indent=4) except Exception as ex: return 'Failed to load and insert pipeline. ' + str(ex), 400