from pathlib import Path

from immuneML.environment.Label import Label
from immuneML.hyperparameter_optimization.states.TrainMLModelState import TrainMLModelState
from immuneML.reports.Report import Report


class TrainMLModelReport(Report):
    """
    Train ML model reports plot general statistics or export data of multiple models simultaneously when running the :ref:`TrainMLModel` instruction.

    In the :ref:`TrainMLModel` instruction, train ML model reports can be specified under 'reports'. Example:

    .. indent with spaces
    .. code-block:: yaml

        my_instruction:
            type: TrainMLModel
            reports:
                - my_train_ml_model_report
            # other parameters...
    """
    DOCS_TITLE = "Train ML model reports"

    def __init__(self, name: str = None, state: TrainMLModelState = None, label: Label = None, result_path: Path = None, number_of_processes: int = 1):
        '''
        The arguments defined below are set at runtime by the instruction.

        Concrete classes inheriting TrainMLModelReport may include additional parameters that will be set by the user in the form of input arguments.
        name (str): user-defined name of the report used in the HTML overview automatically generated by the platform
        state (TrainMLModelState): a state object that includes all the information, trained models, encodings and datasets from the nested cross-validation procedure used to train the optimal model.
        result_path (Path): location where the report results will be stored
        number_of_processes (int): how many processes should be created at once to speed up the analysis. For personal machines, 4 or 8 is usually a good choice.
        '''
        super().__init__(name=name, result_path=result_path, number_of_processes=number_of_processes)
        self.state = state
        self.label = label

