mmcdermott / multisource_args

A simple utility for maintaining arguments that can be used across multiple interfaces (predominately CLI and Jupyter Notebooks)
MIT License
0 stars 0 forks source link

Checking Against Spec #7

Open mmcdermott opened 3 years ago

mmcdermott commented 3 years ago

It could be nice to have these args be able to be validated against a function target:

   arg_names = inspect.getfullargspec(pretrain_fn).args

    missing = set(arg_names) - set(arg_dict.keys())
    extra = set(arg_dict.keys()) - set(arg_names)
    if missing:
        raise RuntimeError(f"Missing arguments: {missing}")
    if extra:
        logger.warning(f"Extra arguments that would be ignored: {extra}")
        for key in extra:
            del arg_dict[key]