def test_execution_stats(self): from compmake import comp, batch_command # schedule some commands res = comp(f, comp(f), comp(f, comp(f))) result = compmake_execution_stats(res) batch_command('make') res = get_job_userobject(result.job_id) assert isinstance(res, dict) res['cpu_time'] res['wall_time'] res['jobs'] print res
def dump(non_empty_job_list, directory='.'): '''Dumps the content of jobs as pickle files. Arguments: directory='.' where to dump the files ''' for job_id in non_empty_job_list: if is_job_userobject_available(job_id): user_object = get_job_userobject(job_id) filename = os.path.join(directory, job_id + '.pickle') with open(filename, 'w') as f: pickle.dump(user_object, f) info('Wrote %s' % filename) else: user_error('Job %s is not ready yet.' % job_id)
def report_results_pairs_jobs(context, func, objspec1_name, objspec2_name, jobs): """ This version gets the jobs ID """ reason2symbol = {} def get_string_result(res): if res is None: s = 'ok' elif isinstance(res, Skipped): s = 'skipped' reason = res.get_reason() if not reason in reason2symbol: reason2symbol[reason] = len(reason2symbol) + 1 s += '(%s)' % reason2symbol[reason] elif isinstance(res, PartiallySkipped): parts = res.get_skipped_parts() s = 'no ' + ','.join(parts) else: print('how to interpret %s? ' % describe_value(res)) s = '?' return s r = Report() if not jobs: r.text('warning', 'no test objects defined') return r rows = sorted(set([a for a, _ in jobs])) cols = sorted(set([b for _, b in jobs])) data = [[None for a in range(len(cols))] for b in range(len(rows))] # a nice bug: data = [[None * len(cols)] * len(rows) db = context.get_compmake_db() comb = itertools.product(enumerate(rows), enumerate(cols)) for ((i, id_object1), (j, id_object2)) in comb: job_id = jobs[(id_object1, id_object2)] cache = get_job_cache(job_id, db) if cache.state == Cache.DONE: res = get_job_userobject(job_id, db) s = get_string_result(res) elif cache.state == Cache.FAILED: s = 'FAIL' elif cache.state == Cache.BLOCKED: s = 'blocked' # elif cache.state == Cache.IN_PROGRESS: # s = '(in progress)' elif cache.state == Cache.NOT_STARTED: s = ' ' data[i][j] = s r.table('summary', rows=rows, data=data, cols=cols) expl = "" for reason, symbol in reason2symbol.items(): expl += '(%s): %s\n' % (symbol, reason) r.text('notes', expl) return r
def report_results_pairs_jobs(context, func, objspec1_name, objspec2_name, jobs): """ This version gets the jobs ID """ reason2symbol = {} def get_string_result(res): if res is None: s = 'ok' elif isinstance(res, Skipped): s = 'skipped' reason = res.get_reason() if not reason in reason2symbol: reason2symbol[reason] = len(reason2symbol) + 1 s += '(%s)' % reason2symbol[reason] elif isinstance(res, PartiallySkipped): parts = res.get_skipped_parts() s = 'no ' + ','.join(parts) else: print('how to interpret %s? ' % describe_value(res)) s = '?' return s r = Report() if not jobs: r.text('warning', 'no test objects defined') return r rows = sorted(set([a for a, _ in jobs])) cols = sorted(set([b for _, b in jobs])) data = [[None for a in range(len(cols))] for b in range(len(rows))] # a nice bug: data = [[None * len(cols)] * len(rows) db = context.get_compmake_db() comb = itertools.product(enumerate(rows), enumerate(cols)) for ((i, id_object1), (j, id_object2)) in comb: job_id = jobs[(id_object1, id_object2)] cache = get_job_cache(job_id, db) if cache.state == Cache.DONE: res = get_job_userobject(job_id, db) s = get_string_result(res) elif cache.state == Cache.FAILED: s = 'FAIL' elif cache.state == Cache.BLOCKED: s = 'blocked' # elif cache.state == Cache.IN_PROGRESS: # s = '(in progress)' elif cache.state == Cache.NOT_STARTED: s = ' ' else: s = '?' data[i][j] = s r.table('summary', rows=rows, data=data, cols=cols) expl = "" for reason, symbol in list(reason2symbol.items()): expl += '(%s): %s\n' % (symbol, reason) r.text('notes', expl) return r