Other functions
Other functions#
- b2luigi.core.utils.product_dict(**kwargs: Any) Iterator[Dict[str, Any]] #
Cross-product the given parameters and return a list of dictionaries.
Example
>>> list(product_dict(arg_1=[1, 2], arg_2=[3, 4])) [{'arg_1': 1, 'arg_2': 3}, {'arg_1': 1, 'arg_2': 4}, {'arg_1': 2, 'arg_2': 3}, {'arg_1': 2, 'arg_2': 4}]
The thus produced list can directly be used as inputs for a required tasks:
def requires(self): for args in product_dict(arg_1=[1, 2], arg_2=[3, 4]): yield some_task(**args)
- Parameters
kwargs – Each keyword argument should be an iterable
- Returns
A list of kwargs where each list of input keyword arguments is cross-multiplied with every other.