def get_result(rid): try: res_list = shelve_db.get_results() r = res_list[rid] return jsonify({'result': get_public_result(r)}) except KeyError: abort(404)
def start_analysis(arg_dict): """After performing the setup procedure, start the t-tests. This needs the following arguments: - pid (int): ID of the running project - res_list (list of results): List of result objects for this project - groups (num_config x numtraces array of int): List of groupings per t-test """ try: proj_list = shelve_db.get_projects() res_list = shelve_db.get_results() # Update the project status pid = arg_dict['pid'] proj = proj_list[pid] status = arg_dict['status'] proj.status = status # Check if setup ended successfully; if not, end early setup_ok = arg_dict['setup_ok'] if not setup_ok: proj.running = False proj_list[pid] = proj return # Add new results objects and refer to them in project leak_names = arg_dict['leak_names'] res_list = [] for lname in leak_names: res = Result(proj.id, lname) res_list.append(res) rids = [r.id for r in res_list] proj.results = rids proj.remaining = len(rids) proj_list[pid] = proj # Run worker threads groups = arg_dict['groups'] numtraces = arg_dict['numtraces'] tracelen = arg_dict['tracelen'] max_threads = arg_dict['max_threads'] pool = mp.Pool(max_threads) for i in range(len(groups)): pool.apply_async(worker_thread, args=(groups[i], numtraces, tracelen, proj.cwproject, res_list[i]), callback=update_result) pool.close() except: print traceback.format_exc() raise
def update_result(res): """Find a result with this ID and update its status and data. """ proj_list = shelve_db.get_projects() res_list = shelve_db.get_results() res_list[res.id] = res try: proj = proj_list[res.pid] proj.remaining -= 1 if proj.remaining == 0: proj.running = False proj.status = "finished" proj_list[res.pid] = proj except KeyError: raise KeyError( "Error in result %d - could not find parent project %d" % (res.id, res.pid))
def get_summary(pid): try: proj_list = shelve_db.get_projects() res_list = shelve_db.get_results() p = proj_list[pid] test_names = [''] * len(p.results) test_results = [0] * len(p.results) for i in tqdm(range(len(p.results))): rid = p.results[i] # TODO: this loop is pretty slow. # This line is the cause - hopefully switching from Shelve to SQL # will fix it. Until then we can get around 20 it/s r_i = res_list[rid] t_max = max(r_i.data['trace_c']) test_names[i] = r_i.name test_results[i] = t_max ret = {'names': test_names, 't_values': test_results} return jsonify({'summary': ret}) except KeyError: abort(404)
def get_results(): res_list = shelve_db.get_results() return jsonify({"results": [get_public_result_short(res_list[k]) for k in res_list.keys()]})