def tmp_dir_report(jobs, tmpdirs, sched_cfg, width, start_row=None, end_row=None, prefix=''): '''start_row, end_row let you split the table up if you want''' tab = tt.Texttable() headings = ['tmp', 'ready', 'phases'] tab.header(headings) tab.set_cols_dtype('t' * len(headings)) tab.set_cols_align('r' * (len(headings) - 1) + 'l') for i, d in enumerate(sorted(tmpdirs)): if (start_row and i < start_row) or (end_row and i >= end_row): continue phases = sorted(job.job_phases_for_tmpdir(d, jobs)) ready = manager.phases_permit_new_job(phases, sched_cfg) row = [ abbr_path(d, prefix), 'OK' if ready else '--', phases_str(phases) ] tab.add_row(row) tab.set_max_width(width) tab.set_deco(tt.Texttable.BORDER | tt.Texttable.HEADER) tab.set_deco(0) # No borders return tab.draw()
def tmp_dir_report(jobs, tmpdirs, sched_cfg, width, start_row=None, end_row=None, prefix=""): """start_row, end_row let you split the table up if you want""" tab = tt.Texttable() headings = ["tmp", "count", "ready", "phases", "youngest", "eldest"] tab.header(headings) tab.set_cols_dtype("t" * len(headings)) tab.set_cols_align("r" * (len(headings) - 1) + "l") for i, d in enumerate(sorted(tmpdirs)): if (start_row and i < start_row) or (end_row and i >= end_row): continue dir_jobs = [j for j in jobs if j.tmpdir == d] job_age = [j.get_time_wall() for j in dir_jobs] phases = sorted(job.job_phases_for_tmpdir(d, jobs)) ready = manager.phases_permit_new_job(phases, sched_cfg) row = [ abbr_path(d, prefix), len(dir_jobs), "Y" if ready else "N", phases_str(phases), plot_util.time_format(min(job_age)) if job_age else "N/A", plot_util.time_format(max(job_age)) if job_age else "N/A", ] tab.add_row(row) tab.set_max_width(width) tab.set_deco(tt.Texttable.BORDER | tt.Texttable.HEADER) tab.set_deco(0) # No borders return tab.draw()
def test_permit_new_job_too_many_jobs(self): self.assertFalse( manager.phases_permit_new_job([(3, 1), (3, 2), (3, 3)], self.sched_cfg))
def test_permit_new_job_pre_milestone(self): self.assertFalse( manager.phases_permit_new_job([(2, 3), (4, 1)], self.sched_cfg))
def test_permit_new_job_post_milestone(self): self.assertTrue( manager.phases_permit_new_job([(3, 8), (4, 1)], self.sched_cfg))