def main(arg_list : List[str]) -> None: global predictor parser = argparse.ArgumentParser(description= "Produce an html report from the scrape file.") parser.add_argument("-j", "--threads", default=16, type=int) parser.add_argument("--prelude", default=".", type=Path2) parser.add_argument("--verbose", "-v", help="verbose output", action='store_const', const=True, default=False) parser.add_argument("--progress", "-P", help="show progress of files", action='store_const', const=True, default=False) parser.add_argument("--debug", default=False, const=True, action='store_const') parser.add_argument("--output", "-o", help="output data folder name", default="static-report", type=Path2) parser.add_argument("--message", "-m", default=None) parser.add_argument('--context-filter', dest="context_filter", type=str, default=None) parser.add_argument('--chunk-size', dest="chunk_size", type=int, default=4096) parser.add_argument('--weightsfile', default=None) parser.add_argument('--predictor', choices=list(static_predictors.keys()), default=None) parser.add_argument("--num-predictions", dest="num_predictions", type=int, default=3) parser.add_argument('--skip-nochange-tac', default=False, const=True, action='store_const', dest='skip_nochange_tac') parser.add_argument('filenames', nargs="+", help="proof file name (*.v)", type=Path2) args = parser.parse_args(arg_list) cur_commit = subprocess.check_output(["git show --oneline | head -n 1"], shell=True).decode('utf-8').strip() cur_date = datetime.datetime.now() if args.weightsfile: predictor = loadPredictorByFile(args.weightsfile) elif args.predictor: predictor = loadPredictorByName(args.predictor) else: print("You must specify either --weightsfile or --predictor!") parser.print_help() return if not args.output.exists(): args.output.makedirs() context_filter = args.context_filter or dict(predictor.getOptions())["context_filter"] with multiprocessing.pool.ThreadPool(args.threads) as pool: file_results = \ list((stats for stats in pool.imap_unordered(functools.partial(report_file, args, predictor.training_args, context_filter), args.filenames) if stats)) write_summary(args, predictor.getOptions() + [("report type", "static"), ("predictor", args.predictor)], cur_commit, cur_date, file_results)
def main(arg_list: List[str]) -> None: parser = argparse.ArgumentParser( description= "Produce an index file from attempting to complete proofs using Proverbot9001." ) parser.add_argument("-j", "--threads", dest="num_threads", default=16, type=int) parser.add_argument("--output", "-o", help="output data folder name", default="search-report", type=Path2) parser.add_argument('--weightsfile', default=None) parser.add_argument('--predictor', choices=list(static_predictors.keys()), default=None) parser.add_argument('filenames', nargs="+", help="proof file name (*.v)") args, unknown_args = parser.parse_known_args(arg_list) commit, date = get_metadata() base = Path2(os.path.dirname(os.path.abspath(__file__)) + "/..") if not args.output.exists(): args.output.makedirs() with multiprocessing.pool.ThreadPool(args.num_threads) as pool: pool.starmap( functools.partial(run_search, unknown_args, args.output, args.predictor, args.weightsfile), enumerate(args.filenames)) file_args: Optional[argparse.Namespace] = None file_results: List[ReportStats] = [] for filename in args.filenames: csv_args, result = read_stats_from_csv(args.output, filename) csv_args.debug = False csv_args.filename = "" if not file_args: file_args = csv_args else: assert file_args == csv_args, \ f"File {filename} has different args than the others! "\ f"Others args are {csv_args}, file args are {file_args}" file_results.append(result) assert file_args tqdm.write("Writing summary with {} file outputs.".format( len(file_results))) predictorOptions = get_predictor(parser, args).getOptions() write_summary( args, predictorOptions + [("report type", "search"), ("search width", file_args.search_width), ("search depth", file_args.search_depth)], commit, date, file_results)
def main(arg_list: List[str]) -> None: global jobs global num_jobs global net global gresult parser = argparse.ArgumentParser( description="try to match the file by predicting a tactic") parser.add_argument('-j', '--threads', default=16, type=int) parser.add_argument('--prelude', default=".", type=Path2) parser.add_argument('--debug', default=False, const=True, action='store_const') parser.add_argument("--verbose", "-v", help="verbose output", action='store_const', const=True, default=False) parser.add_argument("--progress", "-P", help="show progress of files", action='store_const', const=True, default=False) parser.add_argument('-o', '--output', help="output data folder name", default="report", type=Path2) parser.add_argument('-m', '--message', default=None) parser.add_argument( '--baseline', help="run in baseline mode, predicting {} every time".format( baseline_tactic), default=False, const=True, action='store_const') parser.add_argument('--context-filter', dest="context_filter", type=str, default=None) parser.add_argument('--weightsfile', default=None) parser.add_argument('--predictor', choices=list(static_predictors.keys()), default=None) parser.add_argument('--skip-nochange-tac', default=False, const=True, action='store_const', dest='skip_nochange_tac') parser.add_argument('filenames', nargs="+", help="proof file name (*.v)", type=Path2) args = parser.parse_args(arg_list) coqargs = ["sertop", "--implicit"] includes = subprocess.Popen( ['make', '-C', str(args.prelude), 'print-includes'], stdout=subprocess.PIPE).communicate()[0].decode('utf-8') # Get some metadata cur_commit = subprocess.check_output(["git show --oneline | head -n 1"], shell=True).decode('utf-8').strip() cur_date = datetime.datetime.now() if not args.output.exists(): args.output.makedirs() jobs = queue.Queue() workers = [] num_jobs = len(args.filenames) for infname in args.filenames: jobs.put(infname) args.threads = min(args.threads, len(args.filenames)) if args.weightsfile: net = loadPredictorByFile(args.weightsfile) elif args.predictor: net = loadPredictorByName(args.predictor) else: print("You must specify either --weightsfile or --predictor!") parser.print_help() return gresult = GlobalResult(net.getOptions()) context_filter = args.context_filter or dict( net.getOptions())["context_filter"] for idx in range(args.threads): worker = Worker(idx, coqargs, includes, args.output, args.prelude, args.debug, num_jobs, args.baseline, args.skip_nochange_tac, context_filter, args) worker.start() workers.append(worker) for idx in range(args.threads): finished_id = finished_queue.get() workers[finished_id].join() print("Thread {} finished ({} of {}).".format(finished_id, idx + 1, args.threads)) write_summary(args.output, num_jobs, cur_commit, args.message, args.baseline, cur_date, gresult)
def parse_arguments( args_list: List[str] ) -> Tuple[argparse.Namespace, argparse.ArgumentParser]: parser = argparse.ArgumentParser( description= "Produce an html report from attempting to complete proofs using Proverbot9001." ) parser.add_argument("--prelude", default=".") parser.add_argument("--output", "-o", dest="output_dir", help="output data folder name", default="search-report", type=Path2) parser.add_argument("--debug", "-vv", help="debug output", action='store_true') parser.add_argument("--verbose", "-v", help="verbose output", action='store_true') parser.add_argument("--progress", "-P", help="show progress of files", action='store_true') parser.add_argument("--hardfail", "-f", help="fail when hitting a coq anomaly", action='store_true') parser.add_argument('--context-filter', dest="context_filter", type=str, default=None) parser.add_argument('--weightsfile', default=None) parser.add_argument('--predictor', choices=list(static_predictors.keys()), default=None) parser.add_argument("--search-width", dest="search_width", type=int, default=5) parser.add_argument("--search-depth", dest="search_depth", type=int, default=6) parser.add_argument("--no-resume", dest="resume", action='store_false') parser.add_argument("--overwrite-mismatch", dest="overwrite_mismatch", action='store_true') parser.add_argument("--max-print-term", dest="max_print_term", type=int, default=None) parser.add_argument("--max-print-hyps", dest="max_print_hyps", type=int, default=None) parser.add_argument("--max-print-subgoals", dest="max_print_subgoals", type=int, default=2) parser.add_argument('filename', help="proof file name (*.v)", type=Path2) parser.add_argument("--use-hammer", help="Use Hammer tactic after every predicted tactic", action='store_const', const=True, default=False) known_args, unknown_args = parser.parse_known_args(args_list) return known_args, parser