# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
AutoMlState
"""


from ..utils.entrypoints import Component
from ..utils.utils import try_set


def auto_ml_state(
        engine,
        terminator_args,
        metric='Auc',
        trainer_kind='SignatureBinaryClassifierTrainer',
        requested_learners=None,
        **params):
    """
    **Description**
        State of an AutoML search and search space.

    :param metric: Supported metric for evaluator. (settings).
    :param engine: AutoML engine (pipeline optimizer) that generates
        next candidates. (settings).
    :param trainer_kind: Kind of trainer for task, such as binary
        classification trainer, multiclass trainer, etc. (settings).
    :param terminator_args: Arguments for creating terminator, which
        determines when to stop search. (settings).
    :param requested_learners: Learner set to sweep over (if
        available). (settings).
    """

    entrypoint_name = 'AutoMlState'
    settings = {}

    if metric is not None:
        settings['Metric'] = try_set(
            obj=metric,
            none_acceptable=False,
            is_of_type=str,
            values=[
                'Auc',
                'AccuracyMicro',
                'AccuracyMacro',
                'L1',
                'L2',
                'F1',
                'AuPrc',
                'TopKAccuracy',
                'Rms',
                'LossFn',
                'RSquared',
                'LogLoss',
                'LogLossReduction',
                'Ndcg',
                'Dcg',
                'PositivePrecision',
                'PositiveRecall',
                'NegativePrecision',
                'NegativeRecall',
                'DrAtK',
                'DrAtPFpr',
                'DrAtNumPos',
                'NumAnomalies',
                'ThreshAtK',
                'ThreshAtP',
                'ThreshAtNumPos',
                'Nmi',
                'AvgMinScore',
                'Dbi'])
    if engine is not None:
        settings['Engine'] = try_set(
            obj=engine, none_acceptable=False, is_of_type=dict)
    if trainer_kind is not None:
        settings['TrainerKind'] = try_set(
            obj=trainer_kind,
            none_acceptable=False,
            is_of_type=str,
            values=[
                'SignatureBinaryClassifierTrainer',
                'SignatureMultiClassClassifierTrainer',
                'SignatureRankerTrainer',
                'SignatureRegressorTrainer',
                'SignatureMultiOutputRegressorTrainer',
                'SignatureAnomalyDetectorTrainer',
                'SignatureClusteringTrainer'])
    if terminator_args is not None:
        settings['TerminatorArgs'] = try_set(
            obj=terminator_args, none_acceptable=False, is_of_type=dict)
    if requested_learners is not None:
        settings['RequestedLearners'] = try_set(
            obj=requested_learners, none_acceptable=True, is_of_type=list)

    component = Component(
        name=entrypoint_name,
        settings=settings,
        kind='AutoMlStateBase')
    return component
