def main(configs, timeout=10 * 60): makedirs('data/results', exist_ok=True) for config in configs: outpath = resultpath(config) if path.isfile(outpath): continue out_queue = Queue() def worker(): result = None try: result = run_classification(config) except BaseException as exc: print(traceback.format_exc(), file=stderr) result = {'error': repr(exc)} out_queue.put(result) p = Process(target=worker) try: p.start() p.join(timeout) if not p.is_alive(): result = out_queue.get() else: result = {'error': 'timed out'} out_obj = { 'config': config \ , 'result': result } with gzip.open(outpath, mode='xt') as f: json.dump(utils.namedtuples_replaced(out_obj), f, cls=NamedtupleJSONEncoder, indent=4) finally: if p.is_alive(): p.terminate()
def default(): print("File contents:") with gzip.open(resultpath(config.default_config), mode="rt") as f: for line in f: print(line, end="") print_barline() r = load_result(config.default_config).result print("Error reduction:", error_reduction(r)) print("Prior correctness:", prior_correctness(r)) print("Correctness:", correctness(r))