Ejemplo n.º 1
0
def _init_matplotlib():
    import matplotlib as mpl
    import utool
    backend = mpl.get_backend()
    if not sys.platform.startswith('win32') and not sys.platform.startswith('darwin') and os.environ.get('DISPLAY', None) is None:
        # Write to files if we cannot display
        TARGET_BACKEND = 'PDF'
    else:
        TARGET_BACKEND = 'Qt4Agg'
    if utool.in_main_process():
        if not utool.QUIET and utool.VERBOSE:
            print('--- INIT MPL---')
            print('[main] current backend is: %r' % backend)
            print('[main] mpl.use(%r)' % TARGET_BACKEND)
        if backend != TARGET_BACKEND:
            mpl.use(TARGET_BACKEND, warn=True, force=True)
            backend = mpl.get_backend()
            if not utool.QUIET and utool.VERBOSE:
                print('[main] current backend is: %r' % backend)
        if utool.get_flag('--notoolbar'):
            toolbar = 'None'
        else:
            toolbar = 'toolbar2'
        mpl.rcParams['toolbar'] = toolbar
        mpl.rc('text', usetex=False)
        mpl_keypress_shortcuts = [key for key in mpl.rcParams.keys() if key.find('keymap') == 0]
        for key in mpl_keypress_shortcuts:
            mpl.rcParams[key] = ''
Ejemplo n.º 2
0
def init_matplotlib(verbose=VERBOSE_MPLINIT):
    if ut.in_main_process():
        try:
            # This might be the cause of some issues
            from guitool import __PYQT__  # NOQA
        except ImportError:
            print('[!plotttool] WARNING guitool does not have __PYQT__')
            pass
        return _init_mpl_mainprocess(verbose=verbose)
Ejemplo n.º 3
0
 def __init__(ibs, dbdir=None, ensure=True, wbaddr=None, verbose=True,
              request_dbversion=None, force_serial=None):
     """ Creates a new IBEIS Controller associated with one database """
     #if verbose and ut.VERBOSE:
     print('\n[ibs.__init__] new IBEISController')
     # HACK
     try:
         from ibeis_flukematch import plugin  # NOQA
     except ImportError as ex:
         ut.printex(ex, 'flukematch disabled', iswarning=True)
         print('[ibeis] plugin hack')
     ibs.dbname = None
     # an dict to hack in temporary state
     ibs.const = const
     ibs.readonly = None
     ibs.depc_annot = None
     ibs.depc_image = None
     #ibs.allow_override = 'override+warn'
     ibs.allow_override = True
     if force_serial is None:
         force_serial = not ut.in_main_process()
     ibs.force_serial = force_serial
     # observer_weakref_list keeps track of the guibacks connected to this
     # controller
     ibs.observer_weakref_list = []
     # not completely working decorator cache
     ibs.table_cache = None
     ibs._initialize_self()
     ibs._init_dirs(dbdir=dbdir, ensure=ensure)
     # _send_wildbook_request will do nothing if no wildbook address is
     # specified
     ibs._send_wildbook_request(wbaddr)
     ibs._init_sql(request_dbversion=request_dbversion)
     ibs._init_config()
     if not ut.get_argflag('--noclean') and not ibs.readonly:
         # ibs._init_burned_in_species()
         ibs._clean_species()
     ibs.job_manager = None
     print('[ibs.__init__] END new IBEISController\n')
Ejemplo n.º 4
0
    def __init__(
        ibs,
        dbdir=None,
        ensure=True,
        wbaddr=None,
        verbose=True,
        request_dbversion=None,
        request_stagingversion=None,
        force_serial=None,
    ):
        """ Creates a new IBEIS Controller associated with one database """
        # if verbose and ut.VERBOSE:
        logger.info('\n[ibs.__init__] new IBEISController')

        ibs.dbname = None
        # an dict to hack in temporary state
        ibs.const = const
        ibs.readonly = None
        ibs.depc_image = None
        ibs.depc_annot = None
        ibs.depc_part = None
        # ibs.allow_override = 'override+warn'
        ibs.allow_override = True
        if force_serial is None:
            if ut.get_argflag(
                ('--utool-force-serial', '--force-serial', '--serial')):
                force_serial = True
            else:
                force_serial = not ut.in_main_process()
        # if const.CONTAINERIZED:
        #     force_serial = True
        ibs.force_serial = force_serial
        # observer_weakref_list keeps track of the guibacks connected to this
        # controller
        ibs.observer_weakref_list = []
        # not completely working decorator cache
        ibs.table_cache = None
        ibs._initialize_self()
        ibs._init_dirs(dbdir=dbdir, ensure=ensure)
        # _send_wildbook_request will do nothing if no wildbook address is
        # specified
        ibs._send_wildbook_request(wbaddr)
        ibs._init_sql(
            request_dbversion=request_dbversion,
            request_stagingversion=request_stagingversion,
        )
        ibs._init_config()
        if not ut.get_argflag('--noclean') and not ibs.readonly:
            # ibs._init_burned_in_species()
            ibs._clean_species()
        ibs.job_manager = None

        # Hack for changing the way chips compute
        # by default use serial because warpAffine is weird with multiproc
        is_mac = 'macosx' in ut.get_plat_specifier().lower()
        ibs._parallel_chips = not ibs.force_serial and not is_mac

        ibs.containerized = const.CONTAINERIZED
        ibs.production = const.PRODUCTION

        logger.info('[ibs.__init__] CONTAINERIZED: %s\n' %
                    (ibs.containerized, ))
        logger.info('[ibs.__init__] PRODUCTION: %s\n' % (ibs.production, ))

        # Hack to store HTTPS flag (deliver secure content in web)
        ibs.https = const.HTTPS

        logger.info('[ibs.__init__] END new IBEISController\n')
Ejemplo n.º 5
0
"""
from __future__ import absolute_import, division, print_function
import six
import utool as ut
import numpy as np
import vtool as vt
from ibeis.algo.hots import hstypes
from ibeis.algo.hots import match_chips4 as mc4
from ibeis.algo.hots import distinctiveness_normalizer
from ibeis.algo.hots import automated_params
from six.moves import filter

print, print_, printDBG, rrr, profile = ut.inject(__name__, '[special_query]')

# hack for tests
if ut.in_main_process():
    test_title = ut.get_argval('--test-title', type_=str, default=None)
    if test_title is not None:
        ut.change_term_title(test_title)

USE_VSMANY_HACK = ut.get_argflag('--vsmany-hack')
TEST_VSONE_ERRORS = ut.get_argflag(('--test-vsone-errors', '--vsone-errs'))

TestTup = ut.namedtuple('TestTup',
                        ('qaid_t', 'qaid', 'vsmany_rank', 'vsone_rank'))


def testdata_special_query(dbname=None):
    """ test data for special query doctests """
    import ibeis
    if dbname is None:
Ejemplo n.º 6
0
def init_matplotlib(verbose=VERBOSE_MPLINIT):
    if ut.in_main_process():
        PyQt, pyqt_version = get_pyqt()
        return _init_mpl_mainprocess(verbose=verbose)
Ejemplo n.º 7
0
"""
from __future__ import absolute_import, division, print_function
import six
import utool as ut
import numpy as np
import vtool as vt
from ibeis.algo.hots import hstypes
from ibeis.algo.hots import match_chips4 as mc4
from ibeis.algo.hots import distinctiveness_normalizer
from ibeis.algo.hots import automated_params
from six.moves import filter
print, print_, printDBG, rrr, profile = ut.inject(__name__, '[special_query]')


# hack for tests
if ut.in_main_process():
    test_title = ut.get_argval('--test-title', type_=str, default=None)
    if test_title is not None:
        ut.change_term_title(test_title)


USE_VSMANY_HACK = ut.get_argflag('--vsmany-hack')
TEST_VSONE_ERRORS = ut.get_argflag(('--test-vsone-errors', '--vsone-errs'))


TestTup = ut.namedtuple(
    'TestTup', (
        'qaid_t', 'qaid', 'vsmany_rank', 'vsone_rank'))


def testdata_special_query(dbname=None):
Ejemplo n.º 8
0
#class ColumnsCache(object):
#    def __init__(self):
#        self._cache = {}

#    def __setitem__(self, index, value):
#        self._cache[index] = value

#    def __getitem__(self, index):
#        return self._cache[index]

#    def __delitem__(self, index):
#        del self._cache[index]


API_CACHE = utool.get_flag('--api-cache')
if utool.in_main_process():
    if API_CACHE:
        print('[accessor_decors] API_CACHE IS ENABLED')
    else:
        print('[accessor_decors] API_CACHE IS DISABLED')


def init_tablecache():
    #return utool.ddict(ColumnsCache)
    return utool.ddict(lambda: utool.ddict(dict))


def _delete_items(dict_, key_list):
    invalid_keys = iter(set(key_list) - set(dict_.rows()))
    for key in invalid_keys:
        del dict_[key]
Ejemplo n.º 9
0
    def __init__(ibs,
                 dbdir=None,
                 ensure=True,
                 wbaddr=None,
                 verbose=True,
                 request_dbversion=None,
                 request_stagingversion=None,
                 force_serial=None):
        """ Creates a new IBEIS Controller associated with one database """
        #if verbose and ut.VERBOSE:
        print('\n[ibs.__init__] new IBEISController')
        # HACK
        try:
            from ibeis_flukematch import plugin  # NOQA
        except Exception as ex:
            msg = ('Cannot import the flukematch plugin. '
                   'It does not exist or has not been built.')
            ut.printex(ex, msg, iswarning=True)
        ibs.dbname = None
        # an dict to hack in temporary state
        ibs.const = const
        ibs.readonly = None
        ibs.depc_image = None
        ibs.depc_annot = None
        ibs.depc_part = None
        #ibs.allow_override = 'override+warn'
        ibs.allow_override = True
        if force_serial is None:
            if ut.get_argflag(
                ('--utool-force-serial', '--force-serial', '--serial')):
                force_serial = True
            else:
                force_serial = not ut.in_main_process()
        ibs.force_serial = force_serial
        # observer_weakref_list keeps track of the guibacks connected to this
        # controller
        ibs.observer_weakref_list = []
        # not completely working decorator cache
        ibs.table_cache = None
        ibs._initialize_self()
        ibs._init_dirs(dbdir=dbdir, ensure=ensure)
        # _send_wildbook_request will do nothing if no wildbook address is
        # specified
        ibs._send_wildbook_request(wbaddr)
        ibs._init_sql(request_dbversion=request_dbversion,
                      request_stagingversion=request_stagingversion)
        ibs._init_config()
        if not ut.get_argflag('--noclean') and not ibs.readonly:
            # ibs._init_burned_in_species()
            ibs._clean_species()
        ibs.job_manager = None

        # Hack for changing the way chips compute
        # by default use serial because warpAffine is weird with multiproc
        ibs._parallel_chips = False

        ibs.containerized = ut.get_argflag('--containerized')
        if ibs.containerized:
            print('[ibs.__init__] CONTAINERIZED: True\n')

        print('[ibs.__init__] END new IBEISController\n')