def run_from_cmdline(): parser = argparse.ArgumentParser(''' NOTICE: You probably want to run.py rather than this script. ''') parser.add_argument('--dataset', choices=DATASETS.keys(), help=f'Dataset to benchmark on.', required=True) parser.add_argument('--algorithm', help='Name of algorithm for saving the results.', required=True) parser.add_argument( '--module', help= 'Python module containing algorithm. E.g. "ann_benchmarks.algorithms.annoy"', required=True) parser.add_argument('--constructor', help='Constructer to load from modulel. E.g. "Annoy"', required=True) parser.add_argument( '--count', help='K: Number of nearest neighbours for the algorithm to return.', required=True, type=int) parser.add_argument( '--runs', help= 'Number of times to run the algorihm. Will use the fastest run-time over the bunch.', required=True, type=int) parser.add_argument( '--batch', help= 'If flag included, algorithms will be run in batch mode, rather than "individual query" mode.', action='store_true') parser.add_argument( 'build', help= 'JSON of arguments to pass to the constructor. E.g. ["angular", 100]') parser.add_argument( 'queries', help='JSON of arguments to pass to the queries. E.g. [100]', nargs='*', default=[]) args = parser.parse_args() algo_args = json.loads(args.build) print(algo_args) query_args = [json.loads(q) for q in args.queries] definition = Definition( algorithm=args.algorithm, docker_tag=None, # not needed module=args.module, constructor=args.constructor, arguments=algo_args, query_argument_groups=query_args, disabled=False) run(definition, args.dataset, args.count, args.runs, args.batch)
def run_from_cmdline(): parser = argparse.ArgumentParser() parser.add_argument( '--dataset', # choices=DATASETS.keys(), required=True) parser.add_argument('--algorithm', required=True) parser.add_argument('--module', required=True) parser.add_argument('--constructor', required=True) parser.add_argument('--count', required=True, type=int) parser.add_argument('--runs', required=True, type=int) parser.add_argument('--batch', action='store_true') parser.add_argument('build') parser.add_argument('queries', nargs='*', default=[]) args = parser.parse_args() algo_args = json.loads(args.build) query_args = [json.loads(q) for q in args.queries] definition = Definition( algorithm=args.algorithm, docker_tag=None, # not needed module=args.module, constructor=args.constructor, arguments=algo_args, query_argument_groups=query_args, disabled=False) run(definition, args.dataset, args.count, args.runs, args.batch)
def run_from_cmdline(): parser = argparse.ArgumentParser() parser.add_argument('--dataset', choices=DATASETS.keys(), required=True) parser.add_argument('--algorithm', required=True) parser.add_argument('--module', required=True) parser.add_argument('--constructor', required=True) parser.add_argument('--count', required=True, type=int) parser.add_argument('--json-args', action='store_true') parser.add_argument('-a', '--arg', dest='args', action='append') args = parser.parse_args() if args.json_args: algo_args = [json.loads(arg) for arg in args.args] else: algo_args = args.args definition = Definition( algorithm=args.algorithm, docker_tag=None, # not needed module=args.module, constructor=args.constructor, arguments=algo_args) run(definition, args.dataset, args.count)