Example #1
0
def check_for_updates():
    """
    Check for updates of mindsdb
    it will ask the mindsdb server if there are new versions, if there are it will log a message

    :return: None
    """

    # tmp files
    uuid_file = CONFIG.MINDSDB_STORAGE_PATH + '/../uuid.mdb_base'
    mdb_file = CONFIG.MINDSDB_STORAGE_PATH + '/start.mdb_base'

    uuid_file_path = Path(uuid_file)
    if uuid_file_path.is_file():
        uuid_str = open(uuid_file).read()
    else:
        uuid_str = str(uuid.uuid4())
        try:
            open(uuid_file, 'w').write(uuid_str)
        except:
            log.warning('Cannot store token, Please add write permissions to file:' + uuid_file)
            uuid_str = uuid_str + '.NO_WRITE'

    file_path = Path(mdb_file)
    if file_path.is_file():
        token = open(mdb_file).read()
    else:
        token = '{system}|{version}|{uid}'.format(system=platform.system(), version=__version__, uid=uuid_str)
        try:
            open(mdb_file,'w').write(token)
        except:
            log.warning('Cannot store token, Please add write permissions to file:'+mdb_file)
            token = token+'.NO_WRITE'
    extra = urllib.parse.quote_plus(token)
    try:
        r = requests.get('http://mindsdb.com/updates/check/{extra}'.format(extra=extra), headers={'referer': 'http://check.mindsdb.com/?token={token}'.format(token=token)})
    except:
        log.warning('Could not check for updates')
        return
    try:
        # TODO: Extract version, compare with version in version.py
        ret = r.json()

        if 'version' in ret and ret['version']!= __version__:
            pass
            #log.warning("There is a new version of MindsDB {version}, please do:\n    pip3 uninstall mindsdb\n    pip3 install mindsdb --user".format(version=ret['version']))
        else:
            log.debug('MindsDB is up to date!')

    except:
        log.warning('could not check for MindsDB updates')
Example #2
0
    def set_subtypes(self, data_subtypes):
        if data_subtypes is not None:
            for col in data_subtypes:
                if col not in self._col_map:
                    del data_subtypes[col]
                    log.warning(
                        f'Column {col} not present in your data, ignoring the "{data_subtypes[col]}" subtype you specified for it'
                    )

            self.data_subtypes = data_subtypes
            for col in self.data_subtypes:
                col_subtype = self.data_subtypes[col]
                if col_subtype not in [
                        getattr(DATA_SUBTYPES, x)
                        for x in DATA_SUBTYPES.__dict__ if '__' not in x
                ]:
                    raise Exception(f'Invalid data subtype: {col_subtype}')

                for col_type in DATA_TYPES_SUBTYPES.subtypes:
                    if col_subtype in DATA_TYPES_SUBTYPES.subtypes[col_type]:
                        self.data_types[col] = col_type
Example #3
0
import mindsdb.libs.constants.mindsdb as CONST

from mindsdb.__about__ import __package_name__ as name, __version__
from mindsdb.libs.controllers.predictor import Predictor
from mindsdb.libs.data_types.mindsdb_logger import log

# Data Sources
from mindsdb.libs.data_sources.file_ds import FileDS

# These might not initialized properly since they require optional dependencies, so we wrap them in a try-except and don't export them if the dependencies aren't installed
try:
    from mindsdb.libs.data_sources.s3_ds import S3DS
except:
    pass

try:
    from mindsdb.libs.data_sources.mysql_ds import MySqlDS
except:
    log.warning("MySQL Datasource is not available by default. If you wish to use it, please install mysqlclient or mindsdb[extra_data_sources]")

try:
    from mindsdb.libs.data_sources.postgres_ds import PostgresDS
except:
    log.warning("PostgresDS Datasource is not available by default. If you wish to use it, please install psycopg2 or mindsdb[extra_data_sources]")



from mindsdb.libs.data_sources.clickhouse_ds import ClickhouseDS

MindsDB = Predictor
Example #4
0
def check_for_updates():
    """
    Check for updates of mindsdb
    it will ask the mindsdb server if there are new versions, if there are it will log a message

    :return: None
    """

    # tmp files
    uuid_file = os.path.join(CONFIG.MINDSDB_STORAGE_PATH, '..', 'uuid.mdb_base')
    mdb_file = os.path.join(CONFIG.MINDSDB_STORAGE_PATH, 'start.mdb_base')

    if Path(uuid_file).is_file():
        uuid_str = open(uuid_file).read()
    else:
        uuid_str = str(uuid.uuid4())
        try:
            with open(uuid_file, 'w') as fp:
                fp.write(uuid_str)
        except:
            log.warning(f'Cannot store token, Please add write permissions to file: {uuid_file}')
            uuid_str = f'{uuid_str}.NO_WRITE'

    if Path(mdb_file).is_file():
        token = open(mdb_file, 'r').read()
    else:
        if CONFIG.IS_CI_TEST:
            uuid_str = 'travis'
        token = '{system}|{version}|{uid}'.format(system=platform.system(), version=__version__, uid=uuid_str)
        try:
            open(mdb_file,'w').write(token)
        except:
            log.warning(f'Cannot store token, Please add write permissions to file: {mdb_file}')
            token = f'{token}.NO_WRITE'

    try:
        ret = requests.get('https://public.api.mindsdb.com/updates/check/{token}'.format(token=token), headers={'referer': 'http://check.mindsdb.com/?token={token}'.format(token=token)})
        ret = ret.json()
    except Exception as e:
        try:
            log.warning(f'Got reponse: {ret} from update check server !')
        except:
            log.warning(f'Got no response from update check server !')
        log.warning(f'Could not check for updates, got excetpion {e} !')
        return

    try:
        if 'version' in ret and ret['version']!= __version__:
            log.warning("There is a new version of MindsDB {version}, please do:\n    pip3 uninstall mindsdb\n    pip3 install mindsdb --user".format(version=ret['version']))
        else:
            log.debug('MindsDB is up to date!')
    except:
        log.warning('could not check for MindsDB updates')