def cancel_job(request): """ Cancel nhmmer search. HTTP responses: * 200 - job cancelled * 400 - incorrect input * 500 - internal error """ proxy_result = nhmmer_proxy(request) if proxy_result: return proxy_result msg = messages['cancel'] job_id = request.GET.get('id', '') if not job_id: status = 400 return Response(msg[status], status=status) try: # cancel job job = get_job(job_id)[0] job.cancel() # kill nhmmer process kill_nhmmer_job(job_id) # set query `finished` field query = Query.objects.get(id=job_id) query.finished = datetime.datetime.now() query.save() status = 200 return Response(msg[status], status=status) except: status = 500 return Response(msg[status], status=status)
def job(query: str): message = None if not query.startswith('test'): job_id = utils.get_job_from_string(query) else: job_id = query job = utils.get_job(job_id) if not job: message = f'There isn`t job for word: "{query}"' else: if job.get_error_path(): message = f'Error for job for word: "{query}"' if message: flash(message, 'errors') return redirect(url_for('main')) try: job_results = utils.apply_window(utils.get_results(job)) except FileNotFoundError: return render_template("job.html", meta=job.get_meta(), inprogress=True, data=[], labels=[]) return render_template("job.html", meta=job.get_meta(), data=job_results.data, labels=list(map(str, job_results.labels)))
def get_status(request): """ Get status of an nhmmer search. HTTP responses: * 200 - job found * 400 - job id not provided in the url * 404 - job not found in the queue * 500 - internal error """ proxy_result = nhmmer_proxy(request) if proxy_result: return proxy_result msg = messages['status'] job_id = request.GET.get('id', '') if not job_id: status = 400 return Response(msg[status], status=status) try: job = get_job(job_id)[0] if job: url = request.build_absolute_uri( reverse('nhmmer-job-results') + '?id=%s' % job_id ) return Response(StatusSerializer({ 'id': job.id, 'status': job.get_status(), 'enqueued_at': job.enqueued_at, 'ended_at': job.ended_at, 'expiration': job.meta.get('expiration', None), 'url': url, }).data) else: status = 404 return Response(msg[status], status=status) except: status = 500 return Response(msg[status], status=status)
def job(request, job_id): job_obj = utils.get_job(job_id, request) return render_to_response('job.html', RequestContext(request, { 'job': job_obj } ))
def get_job_view(request): id = request.GET.get("id") ret = utils.get_job(id) return public.success_result_http(ret)
def job(request, job_id): job_obj = utils.get_job(job_id, request) return render_to_response('job.html', RequestContext(request, {'job': job_obj}))