def generate_report(args=None): theJobs = getJobs([args.stats_dir+'/*'+args.year]) print("%%%%%%%% Report for " + args.year + " %%%%%%%%") print() print("--- Summary") groups = collect(theJobs,'group','JOBEND') jobs=[(group,len(groups[group]),sum(groups[group])) for group in groups.keys()] jobs.sort(key=lambda tup: tup[2]) njobs=0 ncpuh=0 for job in jobs: print("%18s: %7d jobs; %12.2f cpu-hours" % job) njobs=njobs+job[1] ncpuh=ncpuh+job[2] print("--------------------------------------------------------") print("%10s %5d jobs; %10.2f cpu-hours" % ("",njobs,ncpuh)) print() if(args.by_queue): queues = collect(theJobs,'queue','JOBEND') for queue in sorted(queues.keys()): groups = collect(queues[queue],'group') print("--- " + queue.upper()) jobs=[(group,len(groups[group]),sum(groups[group])) for group in groups.keys()] jobs.sort(key=lambda tup: tup[2]) njobs=0 ncpuh=0 for job in jobs: print("%18s: %7d jobs; %12.2f cpu-hours" % job) njobs=njobs+job[1] ncpuh=ncpuh+job[2] print("--------------------------------------------------------") print("%10s %5d jobs; %10.2f cpu-hours" % ("",njobs,ncpuh)) print()
def test_collect_group(): theJobs = utils.getJobs(['data/events.Fri_Sep_04_2015']) groups = utils.collect(theJobs,'group').keys() assert len(groups) == 26
def test_getjobs(): theJobs = utils.getJobs(['data/events.Sun_Oct_25_2015']) assert len(theJobs) == 2123
def test_collect_queue(): theJobs = utils.getJobs(['data/events.Sun_Oct_25_2015']) groups = utils.collect(theJobs,'queue','JOBEND') assert len(groups.keys()) == 16