# Path: automlk/metrics.py
# class Metric(object):
#     def __init__(self, name, function, problem_type, best_is_min, need_class=False, binary=False, average=False):
# def rmse(y_act, y_pred):
# def rmsle(y_act, y_pred):
# def gini(y_act, y_pred):
# def gini_normalized(y_act, y_pred):
# def evaluate_metric(y_act, y_pred, metric_name, n_classes):
# 
# Path: automlk/dataset.py
# def get_dataset_list(include_results=False):
#     """
#     get the list of all datasets
# 
#     :param include_results: flag to determine if the status are also retrieved (default = False)
#     :return: list of datasets objects or empty list if error (eg. redis or environment not set)
#     """
#     # try:
#     return [get_dataset(dataset_id, include_results) for dataset_id in get_dataset_ids()]
#     # except:
#     #    return []


from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, BooleanField, SelectField, IntegerField, FileField, SelectMultipleField
from wtforms.validators import DataRequired
from automlk.metrics import metric_list
from automlk.dataset import get_dataset_list


class UpdateTextsetForm(FlaskForm):
    # this is the form to update specific fields of a textset
    name = StringField(validators=[DataRequired()])
    description = TextAreaField()
    source = StringField()
    url = StringField()


class ResetTextsetForm(FlaskForm):
    # form to confirm reset of a textset
    reset_id = StringField('id')
    reset_name = StringField('name')
    reset_description = TextAreaField('description')


class DeleteTextsetForm(FlaskForm):
    # form to confirm delete of a textset
    id = StringField('id')
    name = StringField('name')
    description = TextAreaField('description')


class DupplicateRound(FlaskForm):
    # for to dupplicate a dataset
    dataset = SelectField(choices=[])
    round = TextAreaField('search')

    def set_choices(self, problem_type):

# Path: automlk/metrics.py
# class Metric(object):
#     def __init__(self, name, function, problem_type, best_is_min, need_class=False, binary=False, average=False):
# def rmse(y_act, y_pred):
# def rmsle(y_act, y_pred):
# def gini(y_act, y_pred):
# def gini_normalized(y_act, y_pred):
# def evaluate_metric(y_act, y_pred, metric_name, n_classes):
# 
# Path: automlk/dataset.py
# def get_dataset_list(include_results=False):
#     """
#     get the list of all datasets
# 
#     :param include_results: flag to determine if the status are also retrieved (default = False)
#     :return: list of datasets objects or empty list if error (eg. redis or environment not set)
#     """
#     # try:
#     return [get_dataset(dataset_id, include_results) for dataset_id in get_dataset_ids()]
#     # except:
#     #    return []


# Path: web/app/form.py
from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, BooleanField, SelectField, IntegerField, FileField, SelectMultipleField
from wtforms.validators import DataRequired
from automlk.metrics import metric_list
from automlk.dataset import get_dataset_list



class UpdateTextsetForm(FlaskForm):
    # this is the form to update specific fields of a textset
    name = StringField(validators=[DataRequired()])
    description = TextAreaField()
    source = StringField()
    url = StringField()


class ResetTextsetForm(FlaskForm):
    # form to confirm reset of a textset
    reset_id = StringField('id')
    reset_name = StringField('name')
    reset_description = TextAreaField('description')


class DeleteTextsetForm(FlaskForm):
    # form to confirm delete of a textset
    id = StringField('id')
    name = StringField('name')
    description = TextAreaField('description')


class DupplicateRound(FlaskForm):
    # for to dupplicate a dataset
    dataset = SelectField(choices=[])
    round = TextAreaField('search')

    def set_choices(self, problem_type):

        self.dataset.choices = [(d.dataset_id, '#%s: %s' % (d.dataset_id, d.name)) for d in get_dataset_list() if d.problem_type == problem_type]