import inspect


def get_args_from_dict(fn, params):
    """
    extract function parameters by name from a dict
    :param fn:
    :param params:
    :return: dict
    """
    arg_keys = inspect.signature(fn).parameters.keys()
    return dict((k, params[k]) for k in arg_keys if k in params)