rex.utilities.fun_utils.get_arg_str
- get_arg_str(fun, config)[source]
Get a string representation of positional and keyword arguments required by an input function and provided in the config dictionary.
Example
If the function signature is my_fun(a, b, c=0) and config is {‘a’: 1, ‘b’: 2, ‘c’: 3}, the returned arg_str will be “1, 2, c=3”. The function can also take *args or **kwargs, which will be taken from the “args” and “kwargs” keys in the config. “args” must be mapped to a list, and “kwargs” must be mapped to a dictionary.
- Parameters:
fun (obj) – A callable object with a function signature. The function signature will be parsed for args and kwargs which will be taken from the config.
config (dict) – A namespace of arguments to run fun. Not all entries in config may be used, but all required inputs to fun must be provided in config. Can include “args” and “kwargs” which must be mapped to a list and a dictionary, respectively.
- Returns:
arg_str (str) – Argument string that can be used to call fun programmatically, e.g. fun(arg_str)