def aggregate_unfinished_runs(self, username=None): unfinished_runs = self.get_unfinished_runs(username) runs = {"pending": [], "active": []} for run in unfinished_runs: state = ( "active" if any(task["active"] for task in run["tasks"]) else "pending" ) if state == "pending": run["cores"] = 0 runs[state].append(run) runs["pending"].sort( key=lambda run: ( run["args"]["priority"], run["args"]["itp"] if "itp" in run["args"] else 100, ) ) runs["active"].sort( reverse=True, key=lambda run: ( "sprt" in run["args"], run["args"].get("sprt", {}).get("llr", 0), "spsa" not in run["args"], run["results"]["wins"] + run["results"]["draws"] + run["results"]["losses"], ), ) # Calculate but don't save results_info on runs using info on current machines cores = 0 nps = 0 for m in self.get_machines(): concurrency = int(m["concurrency"]) cores += concurrency nps += concurrency * m["nps"] pending_hours = 0 for run in runs["pending"] + runs["active"]: if cores > 0: eta = remaining_hours(run) / cores pending_hours += eta results = self.get_results(run, False) run["results_info"] = format_results(results, run) if "Pending..." in run["results_info"]["info"]: if cores > 0: run["results_info"]["info"][0] += " (%.1f hrs)" % (eta) if "sprt" in run["args"]: sprt = run["args"]["sprt"] elo_model = sprt.get("elo_model", "BayesElo") if elo_model == "BayesElo": run["results_info"]["info"].append( ("[%.2f,%.2f]") % (sprt["elo0"], sprt["elo1"]) ) else: run["results_info"]["info"].append( ("{%.2f,%.2f}") % (sprt["elo0"], sprt["elo1"]) ) return (runs, pending_hours, cores, nps)
def aggregate_unfinished_runs(self, username=None): unfinished_runs = self.get_unfinished_runs(username) runs = {'pending': [], 'active': []} for run in unfinished_runs: state = 'active' if any(task['active'] for task in run['tasks']) else 'pending' runs[state].append(run) runs['pending'].sort(key=lambda run: (run['args']['priority'], run['args']['itp'] if 'itp' in run['args'] else 100)) runs['active'].sort(reverse=True, key=lambda run: ( 'sprt' in run['args'], run['args'].get('sprt',{}).get('llr',0), 'spsa' not in run['args'], run['results']['wins'] + run['results']['draws'] + run['results']['losses'])) # Calculate but don't save results_info on runs using info on current machines cores = 0 nps = 0 for m in self.get_machines(): concurrency = int(m['concurrency']) cores += concurrency nps += concurrency * m['nps'] pending_hours = 0 for run in runs['pending'] + runs['active']: if cores > 0: eta = remaining_hours(run) / cores pending_hours += eta results = self.get_results(run, False) run['results_info'] = format_results(results, run) if 'Pending...' in run['results_info']['info']: if cores > 0: run['results_info']['info'][0] += ' (%.1f hrs)' % (eta) if 'sprt' in run['args']: sprt = run['args']['sprt'] elo_model = sprt.get('elo_model', 'BayesElo') if elo_model == 'BayesElo': run['results_info']['info'].append(('[%.2f,%.2f]') % (sprt['elo0'], sprt['elo1'])) else: run['results_info']['info'].append(('{%.2f,%.2f}') % (sprt['elo0'], sprt['elo1'])) return (runs, pending_hours, cores, nps)