from pathlib import Path


def parse_model(ctx, param, value):
    """Returns the path or model name depending on if a custom one was passed"""
    params = ctx.params
    if "custom_model" in params and params["custom_model"] is not None:
        return Path(params["custom_model"])
    elif value is None:
        return ctx.default_map['model']
    else:
        return value