def check_job_finished(self, job_id=0, user=None): from app.jobs.jobs import get_job j = get_job(job_id) history = self.get_history(j.get_output_parameter("history_id")) if j.has_permission(user): status = j.check_status() if status == "complete": history = self.get_history( j.get_output_parameter("history_id")) vs = ViewSet(self.db, self.get_viewset_id()) c_d = {"data": [], "columns": []} if len(history["fields"]) > 0: c_d = vs.get_columns_and_data(history["fields"]) graphs = [] tracks = [] for g in self.data["graph_config"]: if g["id"] in history["graphs"]: graphs.append(g) for t in self.data["browser_config"]["state"]: if t["track_id"] in history["tracks"]: tracks.append(t) return { "status": "complete", "columns": c_d["columns"], "data": c_d["data"], "tracks": tracks, "graphs": graphs, "history": history } else: return {"status": status, "history": history}
def process_job(job_id, args=None): from app.jobs.jobs import get_job job = get_job(job_id) if not args: job.process() else: job.process(args)
def check_all_jobs(): types = job_types.keys() jobs = db.session.query(UserJob).filter( UserJob.status.notin_(['complete', 'failed', 'processing']), UserJob.type.in_(types)).all() for j in jobs: try: job = get_job(j.id) job.check_status() except Exception as e: app.logger.exception("Unable to process job #{}".format(j.id))
def get_bw_stats_data(self, job_id=0): from app.jobs.jobs import get_job j = get_job(job_id) wig_names = j.get_input_parameter("wig_names") vs = ViewSet(self.db, self.get_viewset_id()) data = vs.get_wig_stats_data(wig_names) wig_files = [] for track in self.data["browser_config"]["state"]: if track['track_id'] in wig_names: wig_files.append(track) data["tracks"] = wig_files return data
def reprocess_job(job_id): j = get_job(job_id) if j.has_permission(current_user): j.process() return ujson.dumps({ "status": j.job.status, "info": { "inputs": j.job.inputs, "outputs": j.job.outputs }, "success": True }) else: return ujson.dumps({ "success": False, "msg": "You do not have permission" })
def get_cluster_data(self, job_id=0): from app.jobs.jobs import get_job j = get_job(job_id) name = j.get_input_parameter("name") methods = j.get_input_parameter("methods") vs = ViewSet(self.db, self.get_viewset_id()) data = vs.get_cluster_data(name, methods) graph_ids = [] graphs = [] field_graph = name + "_fields" for method in methods: graph_ids.append(name + "_" + method) for graph in self.data["graph_config"]: if graph['id'] in graph_ids: graphs.append(graph) if graph["id"] == field_graph: graphs.append(graph) data["graphs"] = graphs return data
def get_job_info(job_id): j = get_job(job_id) return ujson.dumps(j.get_info())
def get_job_status(id): job = get_job(int(id)) if not job.has_permission(current_user): return ujson.dumps({"success": False, "msg": "Permission denied"}) return ujson.dumps({"success": True, "status": job.job.status})