Here is a dirty and hacky script that I use for bisect, it's a bit
more complex than using barebones git bisect due to our subrepos. I
would suggest you check for the menu on the documentation output to
return success or failure on the test function and it will find the
first commit in which the navbar is broken.

On Wed, Jun 12, 2019 at 6:26 PM Pedro Larroy
<pedro.larroy.li...@gmail.com> wrote:
>
> I would suggest bisecting to find when the navbar was gone. I have a
> python script that I use for bisecting that I can offer.
>
> On Wed, Jun 12, 2019 at 10:28 AM Aaron Markham
> <aaron.s.mark...@gmail.com> wrote:
> >
> > Hi everyone, there's an issue with the navigation for master.  When
> > you browse any of the API docs, the left nav is gone.
> > Here's the issue: https://github.com/apache/incubator-mxnet/issues/15200
> > If anyone has ideas, I'd love to hear them.
> >
> > In the meantime, people browsing the docs are going to have a hard
> > time. I tested defaulting the site to 1.4.1 and this works as
> > expected.
> >
> > I propose that I switch this setting in CI causing the site to switch
> > to 1.4.1 as default until such time master is fixed. Or I can leave it
> > set to 1.4.1 and then update it to 1.5.0 when that goes out. In the
> > past several months I made a lot of progress getting the FAQs,
> > tutorials, and other info pages to default to the latest, and this
> > feature will still be in play. Visitors will only see 1.4.1 content
> > for the API docs and everything else will be the latest, greatest
> > info... which, in many ways is probably ideal.
> >
> > Thoughts/objections?
> >
> > Cheers,
> > Aaron
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Description"""

__author__ = 'Pedro Larroy'
__version__ = '0.1'

import os
import sys
import subprocess
import contextlib
import logging
from subprocess import check_call, check_output
import shutil
from timeit import default_timer as timer
import re


@contextlib.contextmanager
def remember_cwd():
    '''
    Restore current directory when exiting context
    '''
    curdir = os.getcwd()
    try: yield
    finally: os.chdir(curdir)


def get_mxnet_root() -> str:
    curpath = os.path.abspath(os.path.dirname(__file__))

    def is_mxnet_root(path: str) -> bool:
        return os.path.exists(os.path.join(path, ".mxnet_root"))

    while not is_mxnet_root(curpath):
        parent = os.path.abspath(os.path.join(curpath, os.pardir))
        if parent == curpath:
            raise RuntimeError("Got to the root and couldn't find a parent folder with .mxnet_root")
        curpath = parent
    return curpath

def c(cmd):
    check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def clean():
    try:
        os.remove('dev_menu.py')
    except FileNotFoundError as e:
        pass
    c(f'git checkout .'.split())
    c(f'git submodule foreach --recursive git clean -xfd'.split())
    c(f'git reset --hard'.split())
    c(f'git submodule foreach --recursive git reset --hard'.split())
    c(f'git submodule update --init --recursive'.split())
    c(f'git subup'.split())

def run():
    start = timer()
    clean()
    sys.stdout.write("Title: ")
    sys.stdout.flush()
    check_call('git show --pretty=format:%h:%s -s HEAD'.split())
    print()
    print('=========================')
    #c(f'ci/docker/runtime_functions.sh clean_repo'.split())
    shutil.copyfile('../dev_menu.py', './dev_menu.py')
    shutil.copyfile('../cmake_options.yml', './cmake_options.yml')
    end = timer()
    print("Update repo, took: {}s".format(int(end - start)))
    print("Building...")
    start = timer()
    #check_output(f'./dev_menu.py build'.split())
    os.chmod('dev_menu.py', 0o755)
    c(f'./dev_menu.py build'.split())
    end = timer()
    print("Built in {}".format(end - start))
    cwd = os.getcwd()
    c(f'rsync -vaP ../pw_inference/ ./'.split())
    #os.chdir('../pw_inference')
    start = timer()
    output = check_output(f'py3_venv/bin/python pw_inference.py'.split()).decode()
    end = timer()
    print("Inference test took: {}".format(end - start))
    print(output)
    def parse_output(s):
        lines = s.splitlines()
        for l in lines:
            m = re.search('-result-:(\w+):(\d+\.\d+)', l)
            if m:
                return {'h': m.group(1), 't': float(m.group(2))}
        return None

    hash_time = parse_output(output)
    # Good 0.95 / 0.66
    # Bad 0.73 / 0.80 
    if hash_time['t'] < 0.8:
        return 'bad'
    else:
        return 'good'


#    check_call(f'py3_venv/bin/python pw_inference.py'.split())
#    end = timer()
#    print("Took: {}".format(end - start))
#    print("\nWith static\n")
#    start = timer()
#    check_call(f'py3_venv/bin/python pw_inference_static.py'.split())
#    end = timer()
#    print("Took: {}".format(end - start))

def main():
    mxnet_root = sys.argv[1]
    assert(os.path.isdir(mxnet_root) and os.path.isfile(os.path.join(mxnet_root, ".mxnet_root")))
    revs = open("revs.txt", "r")
    os.chdir(mxnet_root)
    clean()
    check_call('git checkout 1c3e964fb616bc6a0a93c69511475cf351e5f622'.split())
    check_call('git bisect reset'.split())
    check_call('git bisect start'.split())
    check_call('git bisect bad 1c3e964fb616bc6a0a93c69511475cf351e5f622'.split())
    check_call('git bisect good e43425154419a384d3320d830131e907e837af06'.split())
    while True:
        try:
            res = run()
            print(f"test RESULT: {res}")
            if res == 'bad':
                clean()
                go = check_output('git bisect bad'.split()).decode()
                print(go)
                if re.search('is the first bad commit', go):
                    return 0
            else:
                clean()
                go = check_output('git bisect good'.split()).decode()
                print(go)
                if re.search('is the first bad commit', go):
                    return 0
        except Exception as e:
            logging.exception("This rev failed")
        print()

    return 1

if __name__ == '__main__':
    sys.exit(main())

Reply via email to