def getUserJobs(view_as): sims = pleiades.getUserResultObjects(view_as) simulations = pleiades.getUserSimulations(view_as) jobs = [] for sim in sims: inJobs = False for job in jobs: if cmp(sim["jobName"], job["name"]) == 0: inJobs = True continue if inJobs == False: completed_path = ( settings.CICLOPS_RESULTS_DIR + "/" + view_as + "/" + sim["jobName"] + "/" + sim["outputPath"][: sim["outputPath"].rfind("/")] + "/" ) if os.path.exists(completed_path): completed = len([name for name in os.listdir(completed_path) if os.path.isfile(completed_path + name)]) else: completed = 0 new_job = {"name": sim["jobName"], "id": sim["id"], "incomplete": 0, "completed": completed, "progress": 4} for s in simulations: if cmp(s["jobName"], new_job["name"]) == 0: if s["unfinishedTasks"] == s["samples"]: new_job["incomplete"] += 1 new_job["incomplete"] += pleiades.getRunningSimulationsCount(new_job["id"]) complete = int(new_job["completed"]) total = int(new_job["incomplete"]) + complete if total == 0: progress = 666 else: progress = round(100 * float(complete) / float(total), 1) new_job["progress"] = progress jobs.append(new_job) return sorted(jobs, key=lambda x: x["name"].lower())
def getUserJobs(view_as): sims = pleiades.getUserResultObjects(view_as) simulations = pleiades.getUserSimulations(view_as) jobs = [] for sim in sims: print "here" inJobs = False for job in jobs: if cmp(sim['jobName'], job['name']) == 0: print "here too" inJobs = True continue if inJobs == False: completed_path = settings.CICLOPS_RESULTS_DIR + "/" + view_as + "/" + sim['jobName'] + '/' + sim['outputPath'][:sim['outputPath'].rfind('/')] + '/' if os.path.exists(completed_path): completed = len([name for name in os.listdir(completed_path) if os.path.isfile(completed_path + name)]) else: completed = 0 new_job = {'name': sim['jobName'], 'id': sim['id'], 'incomplete': 0, 'completed': completed, 'progress': 4} for s in simulations: if cmp(s['jobName'], new_job['name']) == 0: if s['unfinishedTasks'] == s['samples']: new_job['incomplete'] += 1 new_job['incomplete'] += pleiades.getRunningSimulationsCount(new_job['id']) complete = int(new_job['completed']) total = int(new_job['incomplete']) + complete if total == 0: progress = 666 else: progress = round(100 * float(complete) / float(total), 1) new_job['progress'] = progress jobs.append(new_job) return sorted(jobs, key=lambda x:x['name'].lower())
def chart(request, view_as, jobName): if not 'username' in request.session: return HttpResponseRedirect('/pleiades/login/') else: user = request.session['username'] charts = [] results = pleiades.getUserResultObjects(view_as) simulations = pleiades.getUserSimulations(view_as) jobs = [] for sim in results: inJobs = False if cmp(sim['jobName'], jobName) == 0: for job in jobs: if cmp(sim['jobName'], job['name']) == 0: inJobs = True continue if inJobs == False: completed_path = settings.CICLOPS_RESULTS_DIR + "/" + view_as + "/" + sim['jobName'] + '/' + sim['outputPath'][:sim['outputPath'].rfind('/')] + '/' if os.path.exists(completed_path): completed = len([name for name in os.listdir(completed_path) if os.path.isfile(completed_path + name)]) else: completed = 0 new_job = {'name': sim['jobName'], 'id': sim['id'], 'pending': 0, 'running': 0, 'completed': completed} for s in simulations: if cmp(s['jobName'], new_job['name']) == 0: if s['unfinishedTasks'] == s['samples']: new_job['pending'] += 1 new_job['running'] = pleiades.getRunningSimulationsCount(new_job['id']) jobs.append(new_job) if len(jobs) > 0: for job in jobs: pending = str(job['pending']) running = str(job['running']) completed = str(job['completed']) pie = {"rows":[{"c":[{"v":"Completed Simulations"},{"f":completed + " Simulations","v":int(completed)}]}, {"c":[{"v":"Running Simulations"},{"f": running + " Simulations","v":int(running)}]}, {"c":[{"v":"Pending Simulations"},{"f": pending + " Simulations","v":int(pending)}]}], "cols":[{"type":"string","id":"name","label":"name"}, {"type":"number","id":"number1__sum","label":"number1__sum"}], "title": str(job['name'])} charts.append(pie) template = loader.get_template('pleiades/chart.html') c = RequestContext(request, { 'charts': charts, 'id': jobName }) return HttpResponse(template.render(c))
def chart(request, view_as, jobName): if not "username" in request.session: return HttpResponseRedirect("/pleiades/login/") else: user = request.session["username"] charts = [] results = pleiades.getUserResultObjects(view_as) simulations = pleiades.getUserSimulations(view_as) jobs = [] for sim in results: inJobs = False if cmp(sim["jobName"], jobName) == 0: for job in jobs: if cmp(sim["jobName"], job["name"]) == 0: inJobs = True continue if inJobs == False: completed_path = settings.CICLOPS_RESULTS_DIR + "/" + view_as + "/" + sim["jobName"] + "/" if not sim["outputPath"].rfind("/") == -1: completed_path = completed_path + sim["outputPath"][: sim["outputPath"].rfind("/")] + "/" if os.path.exists(completed_path): completed = len( [name for name in os.listdir(completed_path) if os.path.isfile(completed_path + name)] ) else: completed = 0 new_job = {"name": sim["jobName"], "id": sim["id"], "pending": 0, "running": 0, "completed": completed} for s in simulations: if cmp(s["jobName"], new_job["name"]) == 0: if s["unfinishedTasks"] == s["samples"]: new_job["pending"] += 1 new_job["running"] = pleiades.getRunningSimulationsCount(new_job["id"]) jobs.append(new_job) if len(jobs) > 0: for job in jobs: pending = str(job["pending"]) running = str(job["running"]) completed = str(job["completed"]) pie = { "rows": [ {"c": [{"v": "Completed Simulations"}, {"f": completed + " Simulations", "v": int(completed)}]}, {"c": [{"v": "Running Simulations"}, {"f": running + " Simulations", "v": int(running)}]}, {"c": [{"v": "Pending Simulations"}, {"f": pending + " Simulations", "v": int(pending)}]}, ], "cols": [ {"type": "string", "id": "name", "label": "name"}, {"type": "number", "id": "number1__sum", "label": "number1__sum"}, ], "title": str(job["name"]), } charts.append(pie) template = loader.get_template("pleiades/chart.html") c = RequestContext(request, {"charts": charts, "id": jobName}) return HttpResponse(template.render(c))