https://prefect.io logo
a

Alberto de Santos

01/20/2021, 9:06 PM
Hi community, Do you have any idea on how to make a task mapping with two parameters? For instance, parameter1 = [a, b, c] and parameter2 [1,2,3] So how could I make tasks with all the pairs possibilities : (a, 1),(a,2),...? Thanks in advance
j

Jim Crist-Harif

01/20/2021, 9:10 PM
You could pass all the parameters to a task to generate the combinations, then write a task to splat the arguments into your original function. Something like:
Copy code
@task
def make_parameters(parameter1, parameter2):
    return list(itertools.product(parameter1, parameter2))

@task
def apply_func(args):
    return original_func(*args)

apply_func.map(make_parameters(parameter1, parameter2))
a

Alberto de Santos

01/20/2021, 9:19 PM
Awesome. How do you see the option of using
partial
j

Jim Crist-Harif

01/20/2021, 9:21 PM
I'm not sure I understand what you mean. Can you clarify?
4 Views