def main()

in scripts/find_best_ckpt.py [0:0]


def main(path: str, op: str) -> str:
    """Finds the best ckpt path

    Parameters
    ----------
    path : str
        ckpt path
    op : str
        "max" (for mAP for example) or "min" (for loss)

    Returns
    -------
    str
        A ckpt path
    """
    ckpts = list(map(str, Path(path).glob("*.ckpt")))
    if not len(ckpts):
        return

    ckpt_score_dict = {ckpt: get_score(ckpt) for ckpt in ckpts}
    op = max if op == "max" else min
    out = op(ckpt_score_dict, key=ckpt_score_dict.get)
    print(out)  # need to flush for bash
    return out