from typing import Mapping
from typing import List


def _mapping_to_mlflow_hyper_params(mp: Mapping) -> List[str]:
    """
    Transform mapping to param-list arguments for `mlflow run ...` command
    Used to pass hyper-parameters to mlflow entry point (See MLFlow reference for more information)
    All mapping values will be converted to str(`value`)

    >>> _mapping_to_mlflow_hyper_params({"alpha": 1.0, 'epochs': 10})
    ["-P", "alpha=1.0", "-P", "epochs=10"]

    >>> result = _mapping_to_mlflow_hyper_params({"alpha": 1.0, 'epochs': 10})
    >>> assert isinstance(result, List)

    :param mp:
    :return:
    """
    param_list = []
    for k, v in mp.items():
        param_list.append('-P')
        param_list.append(f'{k}={v}')

    return param_list