def load_model(path):
    """Load a model from a pickle file in the data directory. Cached so model is only loaded once."""
    abspath = find_data(path)
    cached = _model_cache.get(abspath)
    if cached is not None:
        log.debug('Using cached copy of %s' % path)
        return cached
    log.debug('Loading model %s' % path)
    try:
        with io.open(abspath, 'rb') as f:
            model = six.moves.cPickle.load(f)
    except IOError:
        raise ModelNotFoundError('Could not load %s. Have you run `cde data download`?' % path)
    _model_cache[abspath] = model
    return model
def load_model ( path ) : abspath = find_data ( path ) cached = _model_cache . get ( abspath ) if cached is not None : log . debug ( 'Using cached copy of %s' % path ) return cached log . debug ( 'Loading model %s' % path ) try : with io . open ( abspath , 'rb' ) as f : model = six . moves . cPickle . load ( f ) except IOError : raise ModelNotFoundError ( 'Could not load %s. Have you run `cde data download`?' % path ) _model_cache [ abspath ] = model return model
Load a model from a pickle file in the data directory. Cached so model is only loaded once.