예제 #1
0
def import_(archive, force, verbose, db):
    "Import an archive of results"
    log = logging.getLogger('TPCH')
    log.info("Extracting TPCH results from archive %s", archive)

    try:
        tpch.control.utils.maybe_install_resdb(db)
    except Exception as err:
        print("Can't connect to %s: %s" % (db, err))
        return

    runs = []
    skipped = []
    with zipfile.ZipFile(archive, mode='r') as zip:
        current_run = None
        for fn in zip.namelist():
            if fn[0:8] != 'aws.out/':
                print("ignoring file %s" % fn)
            relpath = fn[8:]

            run = relpath.split('/')[0]

            if run != current_run:
                current_run = run
                runs.append(current_run)
                if verbose:
                    print("Importing results for run '%s'" % current_run)

            if os.path.exists(fn) and not force:
                if verbose:
                    print("  skipping %s" % fn)
                if current_run not in skipped:
                    skipped.append(current_run)
                continue

            if verbose:
                print("  %s" % fn)

            zip.extract(fn)

    for run in runs:
        if run not in skipped:
            b = bench.Run(run)
            b.merge_results()

        else:
            if verbose:
                print("Skipped files in run '%s', use --force to override" %
                      run)

    print()
    for run in runs:
        if run not in skipped:
            b = bench.Run(run)
            b.list()
            print()
            b.results(verbose=True)
            print()

    return
예제 #2
0
def merge_results(name, db):
    """Merge local results from loaders"""
    try:
        tpch.control.utils.maybe_install_resdb(db)
    except Exception as err:
        print("Can't connect to %s: %s" % (db, err))
        return

    if name:
        run = bench.Run(name, resdb=db)
        run.merge_results()
        print()
        run.list()
        print()

    else:
        for name in tpch.control.utils.list_runs():
            run = bench.Run(name, resdb=db)
            run.merge_results()
        print()

        for name in tpch.control.utils.list_runs():
            run = bench.Run(name, resdb=db)
            run.list()
            print()
예제 #3
0
def export(archive, name, verbose, force):
    "Export bench results into an archive file."
    if force and os.path.exists(archive):
        os.remove(archive)

    try:
        with zipfile.ZipFile(archive, mode='x') as zip:
            if name:
                # the --name argument can be used several times
                # so that we get a list of names here
                namelist = name

                for name in namelist:
                    run = bench.Run(name)
                    print("Archiving results for %s" % run.name)
                    for fn in run.list_result_files():
                        if verbose:
                            print("  %s" % fn)
                        zip.write(fn)
            else:
                for name in tpch.control.utils.list_runs():
                    run = bench.Run(name)
                    print("Archiving results for %s" % run.name)
                    for fn in run.list_result_files():
                        if verbose:
                            print("  %s" % fn)
                        zip.write(fn)

    except FileExistsError as err:
        print("Creation of %s failed: %s" % (archive, err))
예제 #4
0
def update(name, system, running, db):
    """Fetch logs and intermediate results from loaders"""
    try:
        tpch.control.utils.maybe_install_resdb(db)
    except Exception as err:
        print("Can't connect to %s: %s" % (db, err))
        return

    if name:
        r = bench.Run(name, system, resdb=db)
        r.update()

    else:
        for name in tpch.control.utils.list_runs():
            run = bench.Run(name, system, resdb=db)
            run.update(tail=False, results=False)

        # rather than printing a large progress report for each running
        # benchmark we just updated, show the shorter list information
        # screen at the end.
        for name in tpch.control.utils.list_runs():
            run = bench.Run(name, resdb=db)
            if run.is_ready():
                print()
                run.status()

    print()
예제 #5
0
def terminate(name, system, orphans):
    """Terminate loaders, delete database instances"""
    if orphans:
        for name in tpch.control.utils.list_runs():
            r = bench.Run(name, system)

            if r.has_infra() and not r.tpch_is_running():
                r.terminate()
    else:
        r = bench.Run(name, system)
        r.terminate()
예제 #6
0
def status(name, running, db):
    """Display infra status and becnhmark logs"""
    if name:
        r = bench.Run(name, resdb=db)
        r.status(with_results=False)

    else:
        for name in tpch.control.utils.list_runs():
            run = bench.Run(name, resdb=db)
            if running:
                if run.is_ready():
                    run.status(with_results=False)
            else:
                run.status(with_results=False)
    return
예제 #7
0
def list(db, name, running):
    """List currently known benchmarks."""
    if name:
        run = bench.Run(name, resdb=db)
        run.list()
        print()

    else:
        for name in tpch.control.utils.list_runs():
            run = bench.Run(name, resdb=db)
            if running:
                if run.is_ready():
                    run.list()
            else:
                run.list()
            print()
예제 #8
0
def results(name, db, running):
    """Show local benchmark results"""
    if name:
        run = bench.Run(name, resdb=db)
        run.results(verbose=True)
        print()

    else:
        for name in tpch.control.utils.list_runs():
            run = bench.Run(name, resdb=db)

            if running:
                if run.is_ready():
                    run.results(verbose=True)
                    print()
            else:
                run.results(verbose=True)
                print()
    return
예제 #9
0
def infra(name, orphans, dsn):
    """Display infra in use by benchmarks"""
    if name:
        run = bench.Run(name)
        run.list()
        run.list_infra(dsn)

    else:
        for name in tpch.control.utils.list_runs():
            run = bench.Run(name)

            if orphans:
                # only list infra running for no reasons
                if run.has_infra() and not run.tpch_is_running():
                    run.list()
                    run.list_infra(dsn)

            else:
                # here we list everything we know
                run.list_infra(dsn)
    return
예제 #10
0
def benchmark(name, schedule, system):
    """Run the benchmarks"""
    r = bench.Run(name, system)
    r.prepare()
    r.start(schedule)
    return
예제 #11
0
def prepare(name, system):
    """Run the benchmarks"""
    r = bench.Run(name, system)
    r.prepare()
    return
예제 #12
0
def register(name, schedule, system):
    """Register a schedule and the target systems."""
    r = bench.Run(name)
    r.register(schedule, system)
    click.echo('%s: registered schedule %s for systems %s' %
               (name, schedule, ", ".join(r.sysnames)))
예제 #13
0
def cancel(name, system):
    """Terminate loaders, cancel currently running benchmark"""
    r = bench.Run(name, system)
    r.cancel()
예제 #14
0
def tail(name, system, n, f):
    """Connects to the loaders and tail -f tpch.log"""
    r = bench.Run(name, system)
    r.tail(follow=f, n=n)
    return