Пример #1
0
def run_dev(main_locals):
    print('[dev] run_dev')
    # Get references to controller
    ibs  = main_locals['ibs']
    if ibs is not None:
        # Get aids marked as test cases
        qaid_list = main_helpers.get_test_qaids(ibs)
        print('test_qaids = %r' % qaid_list)
        print('len(test_qaids) = %d' % len(qaid_list))
        # Warn on no test cases
        try:
            assert len(qaid_list) > 0, 'assert!'
        except AssertionError as ex:
            utool.printex(ex, 'len(qaid_list) = 0', iswarning=True)
            #qaid_list = ibs.get_valid_aids()[0]

        if len(qaid_list) > 0:
            # Prepare the IBEIS controller for querys
            ibs.prep_qreq_db(qaid_list)
            # Run the dev experiments
            expt_locals = run_experiments(ibs, qaid_list)
            # Add experiment locals to local namespace
            exec(utool.execstr_dict(expt_locals, 'expt_locals'))
            if '--devmode' in sys.argv:
                # Execute the dev-func and add to local namespace
                devfunc_locals = devfunc(ibs, qaid_list)
                exec(utool.execstr_dict(devfunc_locals, 'devfunc_locals'))

    return locals()
Пример #2
0
def run_dev(ibs):
    """
    main developer command

    CommandLine:
        python dev.py --db PZ_Master0 --controlled --print-rankhist
    """
    print('[dev] --- RUN DEV ---')
    # Get reference to controller
    if ibs is not None:
        # Get aids marked as test cases
        if ut.get_argflag('--expanded-aids'):
            ibs, qaid_list, daid_list = main_helpers.testdata_expanded_aids(ibs=ibs)
            print('[run_def] Test Annotations:')
            # print('[run_dev] * qaid_list = %s' % ut.packstr(qaid_list, 80, nlprefix='[run_dev]     '))
        else:
            qaid_list = []
            daid_list = []
        try:
            assert len(qaid_list) > 0, 'assert!'
            assert len(daid_list) > 0, 'daid_list!'
        except AssertionError as ex:
            message = ' (try using command line argument --expanded-aids to enable)'
            utool.printex(ex, 'len(qaid_list) = 0%s' % (message,), iswarning=True)
            utool.printex(ex, 'or len(daid_list) = 0%s' % (message,), iswarning=True)
            # qaid_list = ibs.get_valid_aids()[0]

        if len(qaid_list) > 0 or True:
            # Run the dev experiments
            expt_locals = run_devcmds(ibs, qaid_list, daid_list)
            # Add experiment locals to local namespace
            execstr_locals = utool.execstr_dict(expt_locals, 'expt_locals')
            exec(execstr_locals)

    return locals()
Пример #3
0
def main_loop(main_locals, rungui=True, ipy=False, persist=True):
    """
    Runs the qt loop if the GUI was initialized and returns an executable string
    for embedding an IPython terminal if requested.

    If rungui is False the gui will not loop even if back has been created
    """
    print('[main] ibeis.main_module.main_loop()')
    from ibeis.dev import params
    import utool
    #print('current process = %r' % (multiprocessing.current_process().name,))
    #== 'MainProcess':
    if rungui and not params.args.nogui:
        try:
            _guitool_loop(main_locals, ipy=ipy)
        except Exception as ex:
            print('[main_loop] IBEIS Caught: %s %s' % (type(ex), ex))
            raise
    #if not persist or params.args.cmd:
    #    main_close()
    # Put locals in the exec namespace
    ipycmd_execstr = utool.ipython_execstr()
    locals_execstr = utool.execstr_dict(main_locals, 'main_locals')
    execstr = locals_execstr + '\n' + ipycmd_execstr
    return execstr
Пример #4
0
def main():
    if True:
        import pandas as pd
        pd.options.display.max_rows = 1000
        pd.options.display.width = 1000

        basis = {
            #'n_clusters': [10, 100, 1000, 2000][::-1],
            #'n_features': [4, 32, 128, 512][::-1],
            #'per_cluster': [1, 10, 100, 200][::-1],
            'n_clusters': [10, 100, 500][::-1],
            'n_features': [32, 128][::-1],
            'per_cluster': [1, 10, 20][::-1],
            'asint': [True, False],
        }
        vals = []
        for kw in ut.ProgIter(ut.all_dict_combinations(basis),
                              lbl='gridsearch',
                              bs=False,
                              adjust=False,
                              freq=1):
            print('kw = ' + ut.repr2(kw))
            exec(ut.execstr_dict(kw))
            centers1, new_speed = test_kmeans_plus_plus_speed(fix=True, **kw)
            centers2, old_speed = test_kmeans_plus_plus_speed(fix=False, **kw)
            import utool
            with utool.embed_on_exception_context:
                assert np.all(centers1 == centers2), 'new code disagrees'

            kw['new_speed'] = new_speed
            kw['old_speed'] = old_speed
            vals.append(kw)
            print('---------')

        df = pd.DataFrame.from_dict(vals)
        df['percent_change'] = 100 * (df['old_speed'] -
                                      df['new_speed']) / df['old_speed']
        df = df.reindex_axis(list(basis.keys()) +
                             ['new_speed', 'old_speed', 'percent_change'],
                             axis=1)
        df['absolute_change'] = (df['old_speed'] - df['new_speed'])
        print(df.sort('absolute_change', ascending=False))
        #print(df)

        print(df['percent_change'][df['absolute_change'] > .1].mean())

    #print(df.loc[df['percent_change'].argsort()[::-1]])
    else:
        new_speed = test_kmeans_plus_plus_speed()
        try:
            profile.dump_stats('out.lprof')
            profile.print_stats(stripzeros=True)
        except Exception:
            pass
        print('new_speed = %r' % (new_speed, ))
Пример #5
0
def run_dev(ibs):
    """
    main developer command

    CommandLine:
        python dev.py --db PZ_Master0 --controlled --print-rankhist
    """
    print('[dev] --- RUN DEV ---')
    # Get reference to controller
    if ibs is not None:
        # Get aids marked as test cases
        ibs, qaid_list, daid_list = main_helpers.testdata_expanded_aids(
            ibs=ibs)
        #qaid_list = main_helpers.get_test_qaids(ibs, default_qaids=[1])
        #daid_list = main_helpers.get_test_daids(ibs, default_daids='all', qaid_list=qaid_list)
        print('[run_def] Test Annotations:')
        #print('[run_dev] * qaid_list = %s' % ut.packstr(qaid_list, 80, nlprefix='[run_dev]     '))
        try:
            assert len(qaid_list) > 0, 'assert!'
            assert len(daid_list) > 0, 'daid_list!'
        except AssertionError as ex:
            utool.printex(ex, 'len(qaid_list) = 0', iswarning=True)
            utool.printex(ex, 'or len(daid_list) = 0', iswarning=True)
            #qaid_list = ibs.get_valid_aids()[0]

        if len(qaid_list) > 0 or True:
            # Run the dev experiments
            expt_locals = run_devcmds(ibs, qaid_list, daid_list)
            # Add experiment locals to local namespace
            execstr_locals = utool.execstr_dict(expt_locals, 'expt_locals')
            exec(execstr_locals)
        if ut.get_argflag('--devmode'):
            # Execute the dev-func and add to local namespace
            devfunc_locals = devfunc(ibs, qaid_list)
            exec(utool.execstr_dict(devfunc_locals, 'devfunc_locals'))

    return locals()
Пример #6
0
 def __exit__(self, type_, value, trace):
     if trace is not None:
         print('!!! EMBED ON EXCEPTION !!!')
         print('[util_dbg] %r in context manager!: %s ' % (type_, str(value)))
         import utool
         import traceback
         #traceback.print_stack(type_, value, trace)
         traceback.print_exception(type_, value, trace)
         #parent_locals = utool.get_parent_locals()
         #execstr_parent = utool.execstr_dict(parent_locals, 'parent_locals')
         #exec(execstr_parent)
         trace_locals = trace.tb_frame.f_locals
         execstr_trace = utool.execstr_dict(trace_locals, 'trace_locals')
         exec(execstr_trace)
         utool.embed()
Пример #7
0
 def __exit__(self, type_, value, trace):
     if trace is not None:
         print('!!!!!!!!!!!!!!!!!!!')
         print('[util_dbg] %r in context manager!: %s ' % (type_, str(value)))
         import utool
         import traceback
         #traceback.print_stack(type_, value, trace)
         traceback.print_exception(type_, value, trace)
         #parent_locals = utool.get_parent_locals()
         #execstr_parent = utool.execstr_dict(parent_locals, 'parent_locals')
         #exec(execstr_parent)
         trace_locals = trace.tb_frame.f_locals
         execstr_trace = utool.execstr_dict(trace_locals, 'trace_locals')
         exec(execstr_trace)
         utool.embed()
Пример #8
0
def run_dev(ibs):
    """
    main developer command

    CommandLine:
        python dev.py --db PZ_Master0 --controlled --print-rankhist
    """
    print('[dev] --- RUN DEV ---')
    # Get reference to controller
    if ibs is not None:
        # Get aids marked as test cases
        ibs, qaid_list, daid_list = main_helpers.testdata_expanded_aids(ibs=ibs)
        #qaid_list = main_helpers.get_test_qaids(ibs, default_qaids=[1])
        #daid_list = main_helpers.get_test_daids(ibs, default_daids='all', qaid_list=qaid_list)
        print('[run_def] Test Annotations:')
        #print('[run_dev] * qaid_list = %s' % ut.packstr(qaid_list, 80, nlprefix='[run_dev]     '))
        try:
            assert len(qaid_list) > 0, 'assert!'
            assert len(daid_list) > 0, 'daid_list!'
        except AssertionError as ex:
            utool.printex(ex, 'len(qaid_list) = 0', iswarning=True)
            utool.printex(ex, 'or len(daid_list) = 0', iswarning=True)
            #qaid_list = ibs.get_valid_aids()[0]

        if len(qaid_list) > 0 or True:
            # Run the dev experiments
            expt_locals = run_devcmds(ibs, qaid_list, daid_list)
            # Add experiment locals to local namespace
            execstr_locals = utool.execstr_dict(expt_locals, 'expt_locals')
            exec(execstr_locals)
        if ut.get_argflag('--devmode'):
            # Execute the dev-func and add to local namespace
            devfunc_locals = devfunc(ibs, qaid_list)
            exec(utool.execstr_dict(devfunc_locals, 'devfunc_locals'))

    return locals()
Пример #9
0
def main_loop(main_locals, rungui=True, ipy=False, persist=True):
    """
    Runs the qt loop if the GUI was initialized and returns an executable string
    for embedding an IPython terminal if requested.

    If rungui is False the gui will not loop even if back has been created

    the main locals dict must be callsed main_locals in the scope you call this
    function in.

    Args:
        main_locals (dict_):
        rungui      (bool):
        ipy         (bool):
        persist     (bool):

    Returns:
        str: execstr
    """
    logger.info('[main] wbia.entry_points.main_loop()')
    params.parse_args()
    import utool as ut

    # logger.info('current process = %r' % (multiprocessing.current_process().name,))
    # == 'MainProcess':
    if rungui and not params.args.nogui:
        try:
            _guitool_loop(main_locals, ipy=ipy)
        except Exception as ex:
            ut.printex(ex, 'error in main_loop')
            raise
    # if not persist or params.args.cmd:
    #    main_close()
    # Put locals in the exec namespace
    ipycmd_execstr = ut.ipython_execstr()
    locals_execstr = ut.execstr_dict(main_locals, 'main_locals')
    execstr = locals_execstr + '\n' + ipycmd_execstr
    return execstr
Пример #10
0
def main_loop(main_locals, rungui=True, ipy=False, persist=True):
    """
    Runs the qt loop if the GUI was initialized and returns an executable string
    for embedding an IPython terminal if requested.

    If rungui is False the gui will not loop even if back has been created

    the main locals dict must be callsed main_locals in the scope you call this
    function in.

    Args:
        main_locals (dict_):
        rungui      (bool):
        ipy         (bool):
        persist     (bool):

    Returns:
        str: execstr
    """
    print('[main] ibeis.main_module.main_loop()')
    from ibeis import params
    import utool as ut
    #print('current process = %r' % (multiprocessing.current_process().name,))
    #== 'MainProcess':
    if rungui and not params.args.nogui:
        try:
            _guitool_loop(main_locals, ipy=ipy)
        except Exception as ex:
            ut.printex(ex, 'error in main_loop')
            raise
    #if not persist or params.args.cmd:
    #    main_close()
    # Put locals in the exec namespace
    ipycmd_execstr = ut.ipython_execstr()
    locals_execstr = ut.execstr_dict(main_locals, 'main_locals')
    execstr = locals_execstr + '\n' + ipycmd_execstr
    return execstr
Пример #11
0
def devmain():
    """
    The Developer Script
        A command line interface to almost everything

        -w     # wait / show the gui / figures are visible
        --cmd  # ipython shell to play with variables
        -t     # run list of tests

        Examples:
    """

    helpstr = ut.codeblock(
        '''
        Dev is meant to be run as an interactive script.

        The dev.py script runs any test you regiter with @devcmd in any combination
        of configurations specified by a Config object.

        Dev caches information in order to get quicker results.  # FIXME: Provide quicker results  # FIXME: len(line)
        ''')

    INTRO_TITLE = 'The dev.py Script'
    #INTRO_TEXT = ''.join((ut.bubbletext(INTRO_TITLE, font='cybermedium'), helpstr))
    INTRO_TEXT = ut.bubbletext(INTRO_TITLE, font='cybermedium')

    INTRO_STR = ut.msgblock('dev.py Intro',  INTRO_TEXT)

    EXAMPLE_STR = ut.msgblock('dev.py Examples', ut.codeblock(EXAMPLE_TEXT))

    if ut.NOT_QUIET:
        print(INTRO_STR)
    if ut.get_argflag(('--help', '--verbose')):
        print(EXAMPLE_STR)

    CMD   = ut.get_argflag('--cmd')
    NOGUI = not ut.get_argflag('--gui')

    if len(sys.argv) == 1:
        print('Run dev.py with arguments!')
        sys.exit(1)

    # Run Precommands
    run_devprecmds()

    #
    #
    # Run IBEIS Main, create controller, and possibly gui
    print('++dev')
    main_locals = ibeis.main(gui=ut.get_argflag('--gui'))
    #utool.set_process_title('IBEIS_dev')

    #
    #
    # Load snippet variables
    SNIPPITS = True and CMD
    if SNIPPITS:
        snippet_locals = dev_snippets(main_locals)
        snippet_execstr = utool.execstr_dict(snippet_locals, 'snippet_locals')
        exec(snippet_execstr)

    #
    #
    # Development code
    RUN_DEV = True  # RUN_DEV = '__IPYTHON__' in vars()
    if RUN_DEV:
        dev_locals = run_dev(main_locals['ibs'])
        dev_execstr = utool.execstr_dict(dev_locals, 'dev_locals')
        exec(dev_execstr)

    command = ut.get_argval('--eval', type_=str, default=None)
    if command is not None:
        result = eval(command, globals(), locals())
        print('result = %r' % (result,))
        #ibs.search_annot_notes('360')

    #
    #
    # Main Loop (IPython interaction, or some exec loop)
    #if '--nopresent' not in sys.argv or '--noshow' in sys.argv:
    ut.show_if_requested()
    if ut.get_argflag(('--show', '--wshow')):
        pt.present()
    main_execstr = ibeis.main_loop(main_locals, ipy=(NOGUI or CMD))
    exec(main_execstr)

    #
    #
    # Memory profile
    if ut.get_argflag('--memprof'):
        utool.print_resource_usage()
        utool.memory_profile()

    print('exiting dev')
Пример #12
0
    split_index = NNSplitIndex(ibs, daid_list, num_forests=num_forests)

    #nid_list  = ibs.get_annot_nids(aid_list)
    ##flag_list = ibs.get_annot_exemplar_flag(aid_list)
    #nid2_aids = utool.group_items(aid_list, nid_list)
    #key_list = nid2_aids.keys()
    #val_list = nid2_aids.values()
    #isunknown_list = ibs.is_nid_unknown(key_list)

    #num_forests = 8
    ## Put one name per forest
    #forest_aids, overflow_aids = utool.sample_zip(val_list, num_forests, allow_overflow=True)

    #forest_indexes = []
    #for tx, aids in enumerate(forest_aids):
    #    print('[nn] building forest %d/%d' % (tx + 1, num_forests))
    #    nn_index = NNIndex(ibs, aids)
    #    forest_indexes.append(nn_index)

    return locals()


if __name__ == '__main__':
    multiprocessing.freeze_support()  # For win32
    import ibeis
    main_locals = ibeis.main(defaultdb='GZ_ALL', gui=False)
    ibs = main_locals['ibs']    # IBEIS Control
    test_locals = utool.run_test(TEST_HOTS_SPLITTREE, ibs)
    execstr = utool.execstr_dict(test_locals, 'testdb1')
    exec(execstr)
Пример #13
0
    print('[TEST] read from sql database')

    tt = utool.tic()
    db.cur.execute('SELECT temp_hash FROM temp', [])
    print(' * execute select time=%r sec' % utool.toc(tt))

    tt = utool.tic()
    result_list = _results_gen(db.cur)
    print(' * iter results time=%r sec' % utool.toc(tt))
    print(' * memory(result_list) = %s' %
          utool.byte_str2(utool.get_object_size(result_list)))
    del result_list
    #print('[TEST] result_list=%r' % result_list)

    print('[TEST] dump sql database')
    tt = utool.tic()
    db.dump('temp.dump.txt')
    print(' * dump time=%r sec' % utool.toc(tt))
    #with open('temp.dump.txt') as file_:
    #    print(file_.read())
    return locals()


if __name__ == '__main__':
    import multiprocessing
    multiprocessing.freeze_support()  # For win32
    test_locals = utool.run_test(TEST_SQL_NUMPY)
    execstr = utool.execstr_dict(test_locals, 'test_locals')
    exec(execstr)
Пример #14
0
@profile
def TIME_QUERY(ibs):
    print('[TIME_QUERY]')
    #valid_aids = ibs.get_valid_aids()  # [0:20]
    valid_aids = ibs.get_valid_aids()[0:10]  # [0:20]
    qaid_list = valid_aids
    daid_list = valid_aids

    # Query without using the query cache
    querykw = {
        'use_bigcache': False,
        'use_cache': False,
    }
    with utool.Timer('timing all vs all query'):
        qres_list = ibs.query_chips(qaid_list, daid_list, **querykw)

    print('[/TIME_QUERY]')
    return locals()


if __name__ == '__main__':
    multiprocessing.freeze_support()  # For windows
    import ibeis
    main_locals = ibeis.main(defaultdb='PZ_MOTHERS', gui=False)
    ibs = main_locals['ibs']
    time_locals = TIME_QUERY(ibs)
    execstr = utool.execstr_dict(time_locals, 'time_locals')
    exec(execstr)
    exec(utool.ipython_execstr())
Пример #15
0
    centroids = invindex.words
    num_pca_dims = 3  # 3
    whiten = False
    kwd = dict(
        num_pca_dims=num_pca_dims,
        whiten=whiten,
    )

    #clustertool.rrr()
    def makeplot_(fnum, prefix, data, labels='centroids', centroids=centroids):
        return clustertool.plot_centroids(data,
                                          centroids,
                                          labels=labels,
                                          fnum=fnum,
                                          prefix=prefix + '\n',
                                          **kwd)

    makeplot_(1, 'centroid vecs', centroids)
    #makeplot_(2, 'database vecs', invindex.idx2_dvec)
    #makeplot_(3, 'query vecs', qfx2_vec)
    #makeplot_(4, 'database vecs', invindex.idx2_dvec)
    #makeplot_(5, 'query vecs', qfx2_vec)
    #################


if __name__ == '__main__':
    main_locals = main()
    main_execstr = utool.execstr_dict(main_locals, 'main_locals')
    exec(main_execstr)
    exec(df2.present())
Пример #16
0
    aids_in_gids  = ibs.get_image_aids(gid_list)   # Rois in images
    aids_in_nids  = ibs.get_name_aids(nid_list)    # Rois in images
    img_uuid_list = ibs.get_image_uuids(gid_list)  # Image uuids
    annotation_uuid_list = ibs.get_annot_uuids(aid_list)    # Roi uuids
    #
    #
    # IBEIS Getter methods can take scalars as input too,
    # in this case the output is also a scalar
    #
    gid = gid_list[0]
    gpath = ibs.get_image_paths(gid)  # Get an image path

    # Print locals to the screen
    print('locals() = ' + utool.dict_str(locals()))
    return locals()


if __name__ == '__main__':
    multiprocessing.freeze_support()  # for win32
    main_locals = ibeis.main(defaultdb='testdb1', gui=False)
    ibs = main_locals['ibs']  # IBEIS Controller

    # Run the example
    example_locals = run_example(ibs)
    # Add local variables to main namespace
    exec(utool.execstr_dict(example_locals, 'example_locals'))

    execstr = ibeis.main_loop(main_locals)
    # Pass the --cmd flag to the program to run in IPython mode
    exec(execstr)
Пример #17
0
    from ibeis.dev import dbinfo
    print(ibs.get_infostr())
    dbinfo.get_dbinfo(ibs, verbose=True)
    ################
    print('Inverted Index Stats: vectors per word')
    print(utool.stats_str(map(len, invindex.wx2_idxs.values())))
    ################
    #qfx2_vec     = annots_df['vecs'][1]
    centroids    = invindex.words
    num_pca_dims = 3  # 3
    whiten       = False
    kwd = dict(num_pca_dims=num_pca_dims,
               whiten=whiten,)
    #clustertool.rrr()
    def makeplot_(fnum, prefix, data, labels='centroids', centroids=centroids):
        return clustertool.plot_centroids(data, centroids, labels=labels,
                                          fnum=fnum, prefix=prefix + '\n', **kwd)
    makeplot_(1, 'centroid vecs', centroids)
    #makeplot_(2, 'database vecs', invindex.idx2_dvec)
    #makeplot_(3, 'query vecs', qfx2_vec)
    #makeplot_(4, 'database vecs', invindex.idx2_dvec)
    #makeplot_(5, 'query vecs', qfx2_vec)
    #################


if __name__ == '__main__':
    main_locals = main()
    main_execstr = utool.execstr_dict(main_locals, 'main_locals')
    exec(main_execstr)
    exec(df2.present())
Пример #18
0
    #list(extract_hesaff_sift_feats(cfpath_list, chunksize=16, **genkw))
    #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=16
    # * timed: 124.47361485097099 seconds
    #----------
    #list(extract_hesaff_sift_feats(cfpath_list, chunksize=32, **genkw))
    #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=32
    # * timed: 126.47238857719219 seconds
    #----------
    #list(extract_hesaff_sift_feats(cfpath_list, chunksize=64, **genkw))
    #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=64
    # * timed: 137.3404114996564 seconds

    print('[/TIME_GEN_PREPROC_FEAT]')
    return locals()


if __name__ == '__main__':
    multiprocessing.freeze_support()  # For windows
    import ibeis
    main_locals = ibeis.main(defaultdb='GZ_ALL', gui=False)
    ibs = main_locals['ibs']
    time_locals = {}

    # Varying chunksize seems not to do much on windows :(

    #time_locals.update(TIME_GEN_PREPROC_IMG(ibs))
    time_locals.update(TIME_GEN_PREPROC_FEAT(ibs))
    execstr = utool.execstr_dict(time_locals, 'time_locals')
    exec(execstr)
    exec(utool.ipython_execstr())
Пример #19
0
def devmain():
    """
    The Developer Script
        A command line interface to almost everything

        -w     # wait / show the gui / figures are visible
        --cmd  # ipython shell to play with variables
        -t     # run list of tests

        Examples:
    """

    helpstr = ut.codeblock('''
        Dev is meant to be run as an interactive script.

        The dev.py script runs any test you regiter with @devcmd in any combination
        of configurations specified by a Config object.

        Dev caches information in order to get quicker results.  # FIXME: Provide quicker results  # FIXME: len(line)
        ''')

    INTRO_TITLE = 'The dev.py Script'
    #INTRO_TEXT = ''.join((ut.bubbletext(INTRO_TITLE, font='cybermedium'), helpstr))
    INTRO_TEXT = ut.bubbletext(INTRO_TITLE, font='cybermedium')

    INTRO_STR = ut.msgblock('dev.py Intro', INTRO_TEXT)

    EXAMPLE_STR = ut.msgblock('dev.py Examples', ut.codeblock(EXAMPLE_TEXT))

    if ut.NOT_QUIET:
        print(INTRO_STR)
    if ut.get_argflag(('--help', '--verbose')):
        print(EXAMPLE_STR)

    CMD = ut.get_argflag('--cmd')
    NOGUI = not ut.get_argflag('--gui')

    if len(sys.argv) == 1:
        print('Run dev.py with arguments!')
        sys.exit(1)

    # Run Precommands
    run_devprecmds()

    #
    #
    # Run IBEIS Main, create controller, and possibly gui
    print('++dev')
    main_locals = ibeis.main(gui=ut.get_argflag('--gui'))
    #utool.set_process_title('IBEIS_dev')

    #
    #
    # Load snippet variables
    SNIPPITS = True and CMD
    if SNIPPITS:
        snippet_locals = dev_snippets(main_locals)
        snippet_execstr = utool.execstr_dict(snippet_locals, 'snippet_locals')
        exec(snippet_execstr)

    #
    #
    # Development code
    RUN_DEV = True  # RUN_DEV = '__IPYTHON__' in vars()
    if RUN_DEV:
        dev_locals = run_dev(main_locals['ibs'])
        dev_execstr = utool.execstr_dict(dev_locals, 'dev_locals')
        exec(dev_execstr)

    command = ut.get_argval('--eval', type_=str, default=None)
    if command is not None:
        result = eval(command, globals(), locals())
        print('result = %r' % (result, ))
        #ibs.search_annot_notes('360')

    #
    #
    # Main Loop (IPython interaction, or some exec loop)
    #if '--nopresent' not in sys.argv or '--noshow' in sys.argv:
    ut.show_if_requested()
    if ut.get_argflag(('--show', '--wshow')):
        pt.present()
    main_execstr = ibeis.main_loop(main_locals, ipy=(NOGUI or CMD))
    exec(main_execstr)

    #
    #
    # Memory profile
    if ut.get_argflag('--memprof'):
        utool.print_resource_usage()
        utool.memory_profile()

    print('exiting dev')
Пример #20
0
#!/usr/bin/env python2.7
# TODO: ADD COPYRIGHT TAG
from __future__ import absolute_import, division, print_function
import multiprocessing
import utool
print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_DELETE_ENC]')


def TEST_DELETE_ENC(ibs, back):
    from ibeis.dev import ibsfuncs
    ibsfuncs.update_all_image_encounter(ibs)
    eid_list = ibs.get_valid_eids()
    assert len(eid_list) != 0, "All Image encounter not created"
    eid = eid_list[0]
    ibs.delete_encounters(eid)
    eid_list = ibs.get_valid_eids()
    assert eid not in eid_list, "eid=%r still exists" % (eid,)
    return locals()


if __name__ == '__main__':
    multiprocessing.freeze_support()  # For windows
    import ibeis
    main_locals = ibeis.main(defaultdb='testdb1', gui=False)
    ibs  = main_locals['ibs']   # IBEIS Control
    back = main_locals['back']  # IBEIS GUI backend
    test_locals = utool.run_test(TEST_DELETE_ENC, ibs, back)
    exec(utool.execstr_dict(test_locals, 'test_locals'))
    exec(utool.ipython_execstr())
Пример #21
0
    """
    multiprocessing.freeze_support()  # for win32

    #
    #
    # Run IBEIS Main, create controller, and possibly gui
    print('++dev')
    main_locals = ibeis.main(gui='--gui' in sys.argv)

    #
    #
    # Load snippet variables
    SNIPPITS = True
    if SNIPPITS:
        snippet_locals = dev_snippets(main_locals)
        snippet_execstr = utool.execstr_dict(snippet_locals, 'snippet_locals')
        exec(snippet_execstr)

    #
    #
    # Development code
    RUN_DEV = True  # RUN_DEV = '__IPYTHON__' in vars()
    if RUN_DEV:
        dev_locals = run_dev(main_locals)
        dev_execstr = utool.execstr_dict(dev_locals, 'dev_locals')
        exec(dev_execstr)

    #
    #
    # Main Loop (IPython interaction, or some exec loop)
    if '--nopresent' not in sys.argv: