from typing import Mapping
from typing import List


def _mapping_to_mlflow_run_params(mp: Mapping) -> List[str]:
    """
    Transform parameters from Mapping to list for passing to cmd
    Use --key1 value1 --key2 value2 format

    If value = None than parameter will be included w/o value (Interpreted as a flag)

    >>> _mapping_to_mlflow_run_params({"experiment-id": 2, "no-conda": None})
    ["--experiment-id", "2", "--no-conda"]
    :param mp:
    :return:
    """
    param_list = []
    for k, v in mp.items():
        param_list.append(f'--{k}')
        if v is not None:  # otherwise it is flag
            param_list.append(str(v))
    return param_list