# Path: xcessiv/functions.py
# def hash_file(path, block_size=65536):
# def hash_string(string):
# def import_object_from_path(path, object):
# def import_object_from_string_code(code, object):
# def import_string_code_as_module(code):
# def verify_dataset(X, y):
# def is_valid_json(x):
# def make_serializable(json):
# def get_sample_dataset(dataset_properties):
# def verify_estimator_class(est, meta_feature_generator, metric_generators, dataset_properties):
# def get_path_from_query_string(req):
#     def __init__(self, path):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
# class DBContextManager():
# 
# Path: xcessiv/exceptions.py
# class UserError(Exception):
#     def __init__(self, message, status_code=400, **kwargs):
#     def to_dict(self):
#     def __repr__(self):
# 
# Path: xcessiv/models.py
# class JsonEncodedDict(TypeDecorator):
# class JsonEncodedList(TypeDecorator):
# class Extraction(Base):
# class BaseLearnerOrigin(Base):
# class AutomatedRun(Base):
# class BaseLearner(Base):
# class StackedEnsemble(Base):
#     def process_bind_param(self, value, dialect):
#     def process_result_value(self, value, dialect):
#     def process_bind_param(self, value, dialect):
#     def process_result_value(self, value, dialect):
#     def __init__(self):
#     def return_main_dataset(self):
#     def return_train_dataset(self):
#     def return_test_dataset(self):
#     def __init__(self, source='', name='Base Learner Setup',
#                  meta_feature_generator='predict_proba', metric_generators=None):
#     def serialize(self):
#     def return_estimator(self):
#     def cleanup(self, path):
#     def export_as_file(self, filepath, hyperparameters):
#     def __init__(self, source, job_status, category, base_learner_origin=None):
#     def serialize(self):
#     def __init__(self, hyperparameters, job_status, base_learner_origin):
#     def return_estimator(self):
#     def meta_features_path(self, path):
#     def serialize(self):
#     def delete_meta_features(self, path):
#     def cleanup(self, path):
#     def export_as_file(self, filepath):
#     def __init__(self, secondary_learner_hyperparameters, base_learners,
#                  base_learner_origin, job_status):
#     def return_secondary_learner(self):
#     def export_as_code(self, cv_source):
#     def export_as_file(self, file_path, cv_source):
#     def export_as_package(self, package_path, cv_source):
#     def serialize(self):
# 
# Path: xcessiv/automatedruns.py
# def return_func_to_optimize(path, session, base_learner_origin, default_params,
#                             metric_to_optimize, invert_metric, integers):
#     def func_to_optimize(**params):
# def start_naive_bayes(automated_run, session, path):
# def start_tpot(automated_run, session, path):
# def eval_stacked_ensemble(stacked_ensemble, session, path):
# def start_greedy_ensemble_search(automated_run, session, path):


from rq.decorators import job
from rq import get_current_job
from xcessiv import functions
from xcessiv import exceptions
from xcessiv import models
from xcessiv import automatedruns
from sklearn.model_selection import train_test_split
from six import iteritems
import numpy as np
import os
import sys
import traceback

            np.save(meta_features_path, meta_features, allow_pickle=False)
            base_learner.job_status = 'finished'
            base_learner.meta_features_exists = True
            session.add(base_learner)
            session.commit()

        except:
            session.rollback()
            base_learner.job_status = 'errored'
            base_learner.description['error_type'] = repr(sys.exc_info()[0])
            base_learner.description['error_value'] = repr(sys.exc_info()[1])
            base_learner.description['error_traceback'] = \
                traceback.format_exception(*sys.exc_info())
            session.add(base_learner)
            session.commit()
            raise


@job('default', timeout=86400)
def start_automated_run(path, automated_run_id):
    """Starts automated run. This will automatically create
    base learners until the run finishes or errors out.

    Args:
        path (str): Path to Xcessiv notebook

        automated_run_id (str): Automated Run ID
    """
    with functions.DBContextManager(path) as session:

# Path: xcessiv/functions.py
# def hash_file(path, block_size=65536):
# def hash_string(string):
# def import_object_from_path(path, object):
# def import_object_from_string_code(code, object):
# def import_string_code_as_module(code):
# def verify_dataset(X, y):
# def is_valid_json(x):
# def make_serializable(json):
# def get_sample_dataset(dataset_properties):
# def verify_estimator_class(est, meta_feature_generator, metric_generators, dataset_properties):
# def get_path_from_query_string(req):
#     def __init__(self, path):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
# class DBContextManager():
# 
# Path: xcessiv/exceptions.py
# class UserError(Exception):
#     def __init__(self, message, status_code=400, **kwargs):
#     def to_dict(self):
#     def __repr__(self):
# 
# Path: xcessiv/models.py
# class JsonEncodedDict(TypeDecorator):
# class JsonEncodedList(TypeDecorator):
# class Extraction(Base):
# class BaseLearnerOrigin(Base):
# class AutomatedRun(Base):
# class BaseLearner(Base):
# class StackedEnsemble(Base):
#     def process_bind_param(self, value, dialect):
#     def process_result_value(self, value, dialect):
#     def process_bind_param(self, value, dialect):
#     def process_result_value(self, value, dialect):
#     def __init__(self):
#     def return_main_dataset(self):
#     def return_train_dataset(self):
#     def return_test_dataset(self):
#     def __init__(self, source='', name='Base Learner Setup',
#                  meta_feature_generator='predict_proba', metric_generators=None):
#     def serialize(self):
#     def return_estimator(self):
#     def cleanup(self, path):
#     def export_as_file(self, filepath, hyperparameters):
#     def __init__(self, source, job_status, category, base_learner_origin=None):
#     def serialize(self):
#     def __init__(self, hyperparameters, job_status, base_learner_origin):
#     def return_estimator(self):
#     def meta_features_path(self, path):
#     def serialize(self):
#     def delete_meta_features(self, path):
#     def cleanup(self, path):
#     def export_as_file(self, filepath):
#     def __init__(self, secondary_learner_hyperparameters, base_learners,
#                  base_learner_origin, job_status):
#     def return_secondary_learner(self):
#     def export_as_code(self, cv_source):
#     def export_as_file(self, file_path, cv_source):
#     def export_as_package(self, package_path, cv_source):
#     def serialize(self):
# 
# Path: xcessiv/automatedruns.py
# def return_func_to_optimize(path, session, base_learner_origin, default_params,
#                             metric_to_optimize, invert_metric, integers):
#     def func_to_optimize(**params):
# def start_naive_bayes(automated_run, session, path):
# def start_tpot(automated_run, session, path):
# def eval_stacked_ensemble(stacked_ensemble, session, path):
# def start_greedy_ensemble_search(automated_run, session, path):


# Path: xcessiv/rqtasks.py
from rq.decorators import job
from rq import get_current_job
from xcessiv import functions
from xcessiv import exceptions
from xcessiv import models
from xcessiv import automatedruns
from sklearn.model_selection import train_test_split
from six import iteritems
import numpy as np
import os
import sys
import traceback


            np.save(meta_features_path, meta_features, allow_pickle=False)
            base_learner.job_status = 'finished'
            base_learner.meta_features_exists = True
            session.add(base_learner)
            session.commit()

        except:
            session.rollback()
            base_learner.job_status = 'errored'
            base_learner.description['error_type'] = repr(sys.exc_info()[0])
            base_learner.description['error_value'] = repr(sys.exc_info()[1])
            base_learner.description['error_traceback'] = \
                traceback.format_exception(*sys.exc_info())
            session.add(base_learner)
            session.commit()
            raise


@job('default', timeout=86400)
def start_automated_run(path, automated_run_id):
    """Starts automated run. This will automatically create
    base learners until the run finishes or errors out.

    Args:
        path (str): Path to Xcessiv notebook

        automated_run_id (str): Automated Run ID
    """
    with functions.DBContextManager(path) as session:

        automated_run = session.query(models.AutomatedRun).filter_by(id=automated_run_id).first()