# Path: automlk/config.py
# def set_use_redis(value):
#     """
#     set global value USE_REDIS
# 
#     :param value:
#     :return:
#     """
#     global USE_REDIS
#     USE_REDIS = value
# 
# Path: automlk/xyset.py
# class XySet(object):
#     def __init__(self, X, y, X_train, y_train, X_test, y_test, X_submit,
#                  id_submit, cv_folds, y_eval_list, y_eval, i_eval, i_eval0):
#         """
#         this class stores the various data required for analysis and hyepr-optimisation
# 
#         :param X: X features for the complete dataset (excluding bechnmark/test and submit)
#         :param y: y for this complete set
#         :param X_train: X features for the train set after holdout
#         :param y_train: y for this set
#         :param X_test: X features for the holdout set or test set in benchmark
#         :param y_test: y for this set
#         :param X_submit: X features for the submit set (competition mode only)
#         :param id_submit: y for this set
#         :param cv_folds: cross validation folds
#         :param y_eval_list: list of folds, with indexes for each fold
#         :param y_eval: y for the eval set
#         :param i_eval: indexes for the eval set
#         :param i_eval: indexes for the 1st round of the eval set
#         """
#         self.X = X
#         self.y = y
#         self.X_train = X_train
#         self.y_train = y_train
#         self.X_test = X_test
#         self.y_test = y_test
#         self.X_submit = X_submit
#         self.id_submit = id_submit
#         self.cv_folds = cv_folds
#         self.y_eval_list = y_eval_list
#         self.y_eval = y_eval
#         self.i_eval = i_eval
#         self.i_eval0 = i_eval0


import os
import json
            import redis
from .config import set_use_redis
from .xyset import XySet
                config['graph_theme'] = 'dark'
            if 'doc_theme' not in config.keys():
                config['doc_theme'] = 'default'
            return config
    raise EnvironmentError('configuration file %s not found' % '../config.json')


def set_config(data, theme, bootstrap, graph_theme, store, store_url):
    """
    set config data

    :param data: path to data storage
    :param theme: theme for user interface
    :param bootstrap: specific url for a bootstrap
    :param graph_theme: style for graphs (dark / white)
    :param store: store mode (redis / file)
    :param store_url: url if redis mode
    :return:
    """
    # check data
    if not os.path.exists(data):
        raise EnvironmentError('data folder %s do not exist' % data)

    if store == 'redis':
        # check connection to redis
        try:
            rds = redis.Redis(host=store_url)
            rds.exists('test')
        except:
            raise EnvironmentError('could not connect to redis')

# Path: automlk/config.py
# def set_use_redis(value):
#     """
#     set global value USE_REDIS
# 
#     :param value:
#     :return:
#     """
#     global USE_REDIS
#     USE_REDIS = value
# 
# Path: automlk/xyset.py
# class XySet(object):
#     def __init__(self, X, y, X_train, y_train, X_test, y_test, X_submit,
#                  id_submit, cv_folds, y_eval_list, y_eval, i_eval, i_eval0):
#         """
#         this class stores the various data required for analysis and hyepr-optimisation
# 
#         :param X: X features for the complete dataset (excluding bechnmark/test and submit)
#         :param y: y for this complete set
#         :param X_train: X features for the train set after holdout
#         :param y_train: y for this set
#         :param X_test: X features for the holdout set or test set in benchmark
#         :param y_test: y for this set
#         :param X_submit: X features for the submit set (competition mode only)
#         :param id_submit: y for this set
#         :param cv_folds: cross validation folds
#         :param y_eval_list: list of folds, with indexes for each fold
#         :param y_eval: y for the eval set
#         :param i_eval: indexes for the eval set
#         :param i_eval: indexes for the 1st round of the eval set
#         """
#         self.X = X
#         self.y = y
#         self.X_train = X_train
#         self.y_train = y_train
#         self.X_test = X_test
#         self.y_test = y_test
#         self.X_submit = X_submit
#         self.id_submit = id_submit
#         self.cv_folds = cv_folds
#         self.y_eval_list = y_eval_list
#         self.y_eval = y_eval
#         self.i_eval = i_eval
#         self.i_eval0 = i_eval0


# Path: automlk/context.py
import os
import json
            import redis
from .config import set_use_redis
from .xyset import XySet

                config['graph_theme'] = 'dark'
            if 'doc_theme' not in config.keys():
                config['doc_theme'] = 'default'
            return config
    raise EnvironmentError('configuration file %s not found' % '../config.json')


def set_config(data, theme, bootstrap, graph_theme, store, store_url):
    """
    set config data

    :param data: path to data storage
    :param theme: theme for user interface
    :param bootstrap: specific url for a bootstrap
    :param graph_theme: style for graphs (dark / white)
    :param store: store mode (redis / file)
    :param store_url: url if redis mode
    :return:
    """
    # check data
    if not os.path.exists(data):
        raise EnvironmentError('data folder %s do not exist' % data)

    if store == 'redis':
        # check connection to redis
        try:
            rds = redis.Redis(host=store_url)
            rds.exists('test')
        except:
            raise EnvironmentError('could not connect to redis')

        set_use_redis(True)