예제 #1
0
def prepare_config(config,
                   mindsdb_database='mindsdb',
                   override_integration_config={},
                   override_api_config={},
                   clear_storage=True):
    for key in config._config['integrations']:
        config._config['integrations'][key]['publish'] = False

    if USE_EXTERNAL_DB_SERVER:
        with open(EXTERNAL_DB_CREDENTIALS, 'rt') as f:
            cred = json.loads(f.read())
            for key in cred:
                if f'default_{key}' in config._config['integrations']:
                    config._config['integrations'][f'default_{key}'].update(
                        cred[key])

    for integration in override_integration_config:
        if integration in config._config['integrations']:
            config._config['integrations'][integration].update(
                override_integration_config[integration])
        else:
            config._config['integrations'][
                integration] = override_integration_config[integration]

    for api in override_api_config:
        config._config['api'][api].update(override_api_config[api])

    config['api']['mysql']['database'] = mindsdb_database
    config['api']['mongodb']['database'] = mindsdb_database

    storage_dir = TEMP_DIR.joinpath('storage')
    if storage_dir.is_dir() and clear_storage:
        shutil.rmtree(str(storage_dir))
    config._config['storage_dir'] = str(storage_dir)

    create_dirs_recursive(config.paths)

    temp_config_path = str(TEMP_DIR.joinpath('config.json').resolve())
    with open(temp_config_path, 'wt') as f:
        json.dump(config._config, f, indent=4, sort_keys=True)

    return temp_config_path
예제 #2
0
        root_storage_dir = get_or_create_data_dir()
        os.environ['MINDSDB_STORAGE_DIR'] = root_storage_dir

    if os.path.isdir(root_storage_dir) is False:
        os.makedirs(root_storage_dir)

    if 'storage_db' in user_config:
        os.environ['MINDSDB_DB_CON'] = user_config['storage_db']
    elif os.environ.get('MINDSDB_DB_CON', '') == '':
        os.environ['MINDSDB_DB_CON'] = 'sqlite:///' + os.path.join(
            os.environ['MINDSDB_STORAGE_DIR'],
            'mindsdb.sqlite3.db') + '?check_same_thread=False&timeout=30'

    from mindsdb.utilities.config import Config
    mindsdb_config = Config()
    create_dirs_recursive(mindsdb_config['paths'])

    os.environ['DEFAULT_LOG_LEVEL'] = os.environ.get('DEFAULT_LOG_LEVEL',
                                                     'ERROR')
    os.environ['LIGHTWOOD_LOG_LEVEL'] = os.environ.get('LIGHTWOOD_LOG_LEVEL',
                                                       'ERROR')
    os.environ['MINDSDB_STORAGE_PATH'] = mindsdb_config['paths']['predictors']

    if telemetry_file_exists(mindsdb_config['storage_dir']):
        os.environ['CHECK_FOR_UPDATES'] = '0'
        print('\n x telemetry disabled! \n')
    elif os.getenv('CHECK_FOR_UPDATES', '1').lower() in [
            '0', 'false', 'False'
    ] or mindsdb_config.get('cloud', False):
        disable_telemetry(mindsdb_config['storage_dir'])
        print('\n x telemetry disabled \n')
예제 #3
0
try:
    if not is_notebook():
        args = args_parse()
        if args.config is not None:
            config_path = args.config
except:
    # This fials in some notebooks
    pass

try:
    mindsdb_config = Config(config_path)
except Exception as e:
    print(str(e))
    sys.exit(1)

paths = mindsdb_config.paths
create_dirs_recursive(paths)

os.environ['MINDSDB_STORAGE_PATH'] = paths['predictors']
os.environ['DEFAULT_LOG_LEVEL'] = os.environ.get('DEFAULT_LOG_LEVEL', 'ERROR')
os.environ['LIGHTWOOD_LOG_LEVEL'] = os.environ.get('LIGHTWOOD_LOG_LEVEL',
                                                   'ERROR')

from mindsdb_native import *
# Figure out how to add this as a module
import lightwood
#import dataskillet
import mindsdb.utilities.wizards as wizards
from mindsdb.interfaces.custom.model_interface import ModelInterface
예제 #4
0
if args is not None and args.config is not None:
    config_path = args.config
else:
    config_dir, storage_dir = get_or_create_dir_struct()
    config_path = os.path.join(config_dir, 'config.json')
    if not os.path.isfile(config_path):
        with open(config_path, 'w') as fp:
            json.dump(
                {
                    'config_version': '1.4',
                    'storage_dir': storage_dir,
                    'api': {}
                }, fp)

mindsdb_config = Config(config_path)
create_dirs_recursive(mindsdb_config.paths)

os.environ['DEFAULT_LOG_LEVEL'] = os.environ.get('DEFAULT_LOG_LEVEL', 'ERROR')
os.environ['LIGHTWOOD_LOG_LEVEL'] = os.environ.get('LIGHTWOOD_LOG_LEVEL',
                                                   'ERROR')
os.environ['MINDSDB_CONFIG_PATH'] = config_path
os.environ['MINDSDB_STORAGE_PATH'] = mindsdb_config.paths['predictors']

from mindsdb_native import *
# Figure out how to add this as a module
import lightwood
#import dataskillet
import mindsdb.utilities.wizards as wizards
from mindsdb.interfaces.custom.model_interface import ModelInterface