from pathlib import Path


def get_tmp_path(run):
    """Returns a tmp dir relative to the given mlflow active run.

    Parameters
    ----------
    run : mlflow.ActiveRun
        an mlflow.ActiveRun object

    Returns
    -------
    path : Path
        path to a tmp directory relative to the current run directory
    """

    base_path = run.info.artifact_uri
    if ':' in base_path:
        base_path = base_path[run.info.artifact_uri.index(':') + 1:]
    base_path = Path(base_path).joinpath('..')
    tmp_path = base_path.joinpath('tmp/').resolve()
    tmp_path.resolve().mkdir()

    return tmp_path