from pathlib import Path
from typing import List

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


class MultiDatasetReport(Report):
    '''
    Multi dataset reports are special reports that can be specified when running immuneML with the :py:obj:`~immuneML.api.aggregated_runs.MultiDatasetBenchmarkTool.MultiDatasetBenchmarkTool`.
    See Manuscript use case 1: :ref:`Robustness assessment` for an example.

    When running the :py:obj:`~immuneML.api.aggregated_runs.MultiDatasetBenchmarkTool.MultiDatasetBenchmarkTool`, multi dataset reports can be specified under 'benchmark_reports'.
    Example:

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

        my_instruction:
            type: TrainMLModel
            benchmark_reports:
                - my_benchmark_report
            # other parameters...
    '''
    DOCS_TITLE = "Multi dataset reports"

    def __init__(self, instruction_states: List[TrainMLModelState] = None, name: str = None, result_path: Path = None, number_of_processes: int = 1):
        '''
         When using the reports with MultiDatasetBenchmarkTool, the arguments defined below are set at runtime by the instruction.
        Concrete classes inheriting MultiDatasetReport 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
        result_path (Path): location where the report results will be stored
        instruction_states (list): a list of states for each instruction that was run as a part of the tool, e.g., TrainMLModelState objects
        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.instruction_states = instruction_states
