https://prefect.io logo
Title
c

Choenden Kyirong

04/14/2023, 5:18 AM
is it possible to map over 2 variables that are lists of equal length? For example, i’d like to get this functionality:
@task
def task(x: str, y: int):
    ...


@flow
def flow():
    list_1, list_2 = ['a', 'b'], [1, 2]
    for input_1, input_2 in zip(list_1, list_2):
        task(input_1, input_2)
Would this be done via:
task.map(list_1 , list_2)
Or will prefect only iterate only one of the parameters?
1
t

Tim Galvin

04/14/2023, 5:30 AM
The
.map
operation will behaviour exactly as you are hoping here, so long as those lists are of equal length, The
prefect
unmapped
function (I think it is in the main namespace) can be used to tell prefect not to iterate / zip over something if need be,
task.map(list_1, unmapped(list_2))
if you want
list_2
to be passed in complete form to each call into
task
:thank-you: 2
c

Choenden Kyirong

04/14/2023, 5:32 AM
@Tim Galvin sweet! just tested it out as well. seems to be working.