|
| 1 | +import subprocess |
| 2 | +import argparse |
| 3 | +import pathlib |
| 4 | +import sys |
| 5 | +import os |
| 6 | + |
| 7 | +# Load database reporting functions |
| 8 | +pathToReportDir = os.path.join(pathlib.Path(__file__).parent, "report") |
| 9 | +sys.path.insert(1, pathToReportDir) |
| 10 | +import report |
| 11 | + |
| 12 | +parser = argparse.ArgumentParser(description='Run arbitrary omnisci benchmark and submit report values to MySQL database') |
| 13 | +optional = parser._action_groups.pop() |
| 14 | +required = parser.add_argument_group("required arguments") |
| 15 | +parser._action_groups.append(optional) |
| 16 | + |
| 17 | +# Benchmark scripts location |
| 18 | +required.add_argument('-path', dest="benchmarks_path", required=True, |
| 19 | + help="Path to omniscidb/Benchmarks directory.") |
| 20 | +# Omnisci server parameters |
| 21 | +required.add_argument("-u", "--user", dest="user", default="admin", required=True, |
| 22 | + help="User name to use on omniscidb server.") |
| 23 | +required.add_argument("-p", "--passwd", dest="passwd", default="HyperInteractive", required=True, |
| 24 | + help="User password to use on omniscidb server.") |
| 25 | +required.add_argument("-s", "--server", dest="server", default="localhost", required=True, |
| 26 | + help="Omniscidb server host name.") |
| 27 | +required.add_argument("-o", "--port", dest="port", default="6274", required=True, |
| 28 | + help="Omniscidb server port number.") |
| 29 | +required.add_argument("-n", "--name", dest="name", default="omnisci", required=True, |
| 30 | + help="Database name to use on omniscidb server.") |
| 31 | +required.add_argument("-t", "--import-table-name", dest="import_table_name", required=True, |
| 32 | + help="Name of table to import data to. NOTE: This table will be dropped before and after the import test, unless --no-drop-table-[before/after] is specified.") |
| 33 | +# Required by omnisci benchmark scripts |
| 34 | +required.add_argument("-l", "--label", dest="label", required=True, |
| 35 | + help="Benchmark run label") |
| 36 | +required.add_argument("-f", "--import-file", dest="import_file", required=True, |
| 37 | + help="Absolute path to file or wildcard on omnisci_server machine with data for import test. If wildcard is used, multiple COPY statements are executed to import every file. Number of files may be limited by --max-import-files switch.") |
| 38 | +required.add_argument("-c", "--table-schema-file", dest="table_schema_file", required=True, |
| 39 | + help="Path to local file with CREATE TABLE sql statement for the import table") |
| 40 | +required.add_argument("-d", "--queries-dir", dest="queries_dir", |
| 41 | + help='Absolute path to dir with query files. [Default: "queries" dir in same location as script]') |
| 42 | +required.add_argument("-i", "--iterations", dest="iterations", type=int, required=True, |
| 43 | + help="Number of iterations per query. Must be > 1") |
| 44 | + |
| 45 | +# Fragment size |
| 46 | +optional.add_argument('-fs', dest="fragment_size", action='append', type=int, |
| 47 | + help="Fragment size to use for created table. Multiple values are allowed and encouraged. If no -fs switch is specified, default fragment size is used and templated CREATE TABLE sql files cannot be used.") |
| 48 | +optional.add_argument("--max-import-files", dest="max_import_files", |
| 49 | + help="Maximum number of files to import when -f specifies a wildcard.") |
| 50 | + |
| 51 | +# MySQL database parameters |
| 52 | +optional.add_argument("-db-server", default="localhost", help="Host name of MySQL server") |
| 53 | +optional.add_argument("-db-port", default=3306, type=int, help="Port number of MySQL server") |
| 54 | +optional.add_argument("-db-user", default="", help="Username to use to connect to MySQL database. If user name is specified, script attempts to store results in MySQL database using other -db-* parameters.") |
| 55 | +optional.add_argument("-db-pass", default="omniscidb", help="Password to use to connect to MySQL database") |
| 56 | +optional.add_argument("-db-name", default="omniscidb", help="MySQL database to use to store benchmark results") |
| 57 | + |
| 58 | +optional.add_argument("-commit", default="1234567890123456789012345678901234567890", help="Commit hash to use to record this benchmark results") |
| 59 | + |
| 60 | +args = parser.parse_args() |
| 61 | + |
| 62 | +import_cmdline = ['python3', |
| 63 | + os.path.join(args.benchmarks_path, 'run_benchmark_import.py'), |
| 64 | + '-u', args.user, |
| 65 | + '-p', args.passwd, |
| 66 | + '-s', args.server, |
| 67 | + '-o', args.port, |
| 68 | + '-n', args.name, |
| 69 | + '-t', args.import_table_name, |
| 70 | + '-l', args.label, |
| 71 | + '-f', args.import_file, |
| 72 | + '-c', args.table_schema_file, |
| 73 | + '-e', 'output', |
| 74 | + '-v', |
| 75 | + '--no-drop-table-after'] |
| 76 | + |
| 77 | +benchmark_cmdline = ['python3', |
| 78 | + os.path.join(args.benchmarks_path, 'run_benchmark.py'), |
| 79 | + '-u', args.user, |
| 80 | + '-p', args.passwd, |
| 81 | + '-s', args.server, |
| 82 | + '-o', args.port, |
| 83 | + '-n', args.name, |
| 84 | + '-t', args.import_table_name, |
| 85 | + '-l', args.label, |
| 86 | + '-d', args.queries_dir, |
| 87 | + '-i', str(args.iterations), |
| 88 | + '-e', 'file_json', |
| 89 | + '-j', 'benchmark.json', |
| 90 | + '-v'] |
| 91 | + |
| 92 | +def execute_process(cmdline): |
| 93 | + try: |
| 94 | + process = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 95 | + out = process.communicate()[0].strip().decode() |
| 96 | + print(out) |
| 97 | + except OSError as err: |
| 98 | + print("Failed to start", omnisciCmdLine, err) |
| 99 | + if process.returncode != 0: |
| 100 | + print("Command returned", process.returncode) |
| 101 | + sys.exit() |
| 102 | + |
| 103 | +def execute_benchmark(fragment_size): |
| 104 | + cmdline = import_cmdline |
| 105 | + if fragment_size is not None: |
| 106 | + cmdline += ['--fragment_size', str(fragment_size)] |
| 107 | + execute_process(cmdline) |
| 108 | + |
| 109 | + cmdline = benchmark_cmdline |
| 110 | + execute_process(cmdline) |
| 111 | + |
| 112 | +if args.fragment_size is not None: |
| 113 | + for fs in args.fragment_size: |
| 114 | + print("RUNNING IMPORT WITH FRAGMENT SIZE", fs) |
| 115 | + execute_benchmark(fs) |
| 116 | +else: |
| 117 | + print("RUNNING IMPORT WITH DEFAULT FRAGMENT SIZE") |
| 118 | + execute_benchmark(None) |
| 119 | + |
0 commit comments