Beispiel #1
0
def request_IBEISController(
        dbdir=None, ensure=True, wbaddr=None, verbose=ut.VERBOSE,
        use_cache=True, request_dbversion=None, request_stagingversion=None,
        force_serial=False, asproxy=None, check_hsdb=True):
    r"""
    Alternative to directory instantiating a new controller object. Might
    return a memory cached object

    Args:
        dbdir     (str): databse directory
        ensure    (bool):
        wbaddr    (None):
        verbose   (bool):
        use_cache (bool): use the global ibeis controller cache.
            Make sure this is false if calling from a Thread. (default=True)
        request_dbversion (str): developer flag. Do not use.
        request_stagingversion (str): developer flag. Do not use.

    Returns:
        IBEISController: ibs

    CommandLine:
        python -m ibeis.control.IBEISControl --test-request_IBEISController

    Example:
        >>> # ENABLE_DOCTEST
        >>> from ibeis.control.IBEISControl import *  # NOQA
        >>> dbdir = 'testdb1'
        >>> ensure = True
        >>> wbaddr = None
        >>> verbose = True
        >>> use_cache = False
        >>> ibs = request_IBEISController(dbdir, ensure, wbaddr, verbose,
        >>>                               use_cache)
        >>> result = str(ibs)
        >>> print(result)
    """
    global __IBEIS_CONTROLLER_CACHE__

    if use_cache and dbdir in __IBEIS_CONTROLLER_CACHE__:
        if verbose:
            print('[request_IBEISController] returning cached controller')
        ibs = __IBEIS_CONTROLLER_CACHE__[dbdir]
        if force_serial:
            assert ibs.force_serial, 'set use_cache=False in ibeis.opendb'
    else:
        # Convert hold hotspotter dirs if necessary
        if check_hsdb and ingest_hsdb.check_unconverted_hsdb(dbdir):
            ibs = ingest_hsdb.convert_hsdb_to_ibeis(dbdir, ensure=ensure,
                                                    wbaddr=wbaddr,
                                                    verbose=verbose)
        else:
            ibs = IBEISController(
                dbdir=dbdir, ensure=ensure, wbaddr=wbaddr, verbose=verbose,
                force_serial=force_serial, request_dbversion=request_dbversion,
                request_stagingversion=request_stagingversion)
        __IBEIS_CONTROLLER_CACHE__[dbdir] = ibs
    return ibs
Beispiel #2
0
def preload_convert_hsdb(dbdir):
    """ Convert the database before loading (A bit hacky) """
    from ibeis.dbio import ingest_hsdb
    ingest_hsdb.convert_hsdb_to_ibeis(dbdir,
                                      force_delete=params.args.force_delete)
Beispiel #3
0
def preload_convert_hsdb(dbdir):
    """ Convert the database before loading (A bit hacky) """
    from ibeis.dbio import ingest_hsdb
    ingest_hsdb.convert_hsdb_to_ibeis(dbdir, force_delete=params.args.force_delete)
Beispiel #4
0
def request_IBEISController(
        dbdir=None, ensure=True, wbaddr=None, verbose=ut.VERBOSE,
        use_cache=True, request_dbversion=None, asproxy=None):
    r"""
    Alternative to directory instantiating a new controller object. Might
    return a memory cached object

    Args:
        dbdir     (str): databse directory
        ensure    (bool):
        wbaddr    (None):
        verbose   (bool):
        use_cache (bool): use the global ibeis controller cache.
            Make sure this is false if calling from a Thread. (default=True)
        request_dbversion (str): developer flag. Do not use.

    Returns:
        IBEISController: ibs

    CommandLine:
        python -m ibeis.control.IBEISControl --test-request_IBEISController

    Example:
        >>> # ENABLE_DOCTEST
        >>> from ibeis.control.IBEISControl import *  # NOQA
        >>> dbdir = 'testdb1'
        >>> ensure = True
        >>> wbaddr = None
        >>> verbose = True
        >>> use_cache = False
        >>> ibs = request_IBEISController(dbdir, ensure, wbaddr, verbose,
        >>>                               use_cache)
        >>> result = str(ibs)
        >>> print(result)
    """
    global __IBEIS_CONTROLLER_CACHE__
    if asproxy:
        # Not sure if this is the correct way to do a controller proxy
        from multiprocessing.managers import BaseManager
        class IBEISManager(BaseManager):
            pass
        IBEISManager.register(str('IBEISController'), IBEISController)
        manager = IBEISManager()
        manager.start()
        ibs = manager.IBEISController(
            dbdir=dbdir, ensure=ensure, wbaddr=wbaddr, verbose=verbose,
            request_dbversion=request_dbversion)
        return ibs

    if use_cache and dbdir in __IBEIS_CONTROLLER_CACHE__:
        if verbose:
            print('[request_IBEISController] returning cached controller')
        ibs = __IBEIS_CONTROLLER_CACHE__[dbdir]
    else:
        # Convert hold hotspotter dirs if necessary
        from ibeis.dbio import ingest_hsdb
        if ingest_hsdb.check_unconverted_hsdb(dbdir):
            ibs = ingest_hsdb.convert_hsdb_to_ibeis(dbdir, ensure=ensure,
                                                    wbaddr=wbaddr,
                                                    verbose=verbose)
        else:
            ibs = IBEISController(
                dbdir=dbdir, ensure=ensure, wbaddr=wbaddr, verbose=verbose,
                request_dbversion=request_dbversion)
        __IBEIS_CONTROLLER_CACHE__[dbdir] = ibs
    return ibs