Christian Juhl
11/14/2022, 4:31 PMfrom prefect import task, flow
numbers = {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}
@task
def square_number(number):
return number ** 2
@flow
def my_flow():
squared_numbers = square_number.with_options(tags=numbers.keys()).map(number=numbers.values())
return squared_numbers
if __name__ == '__main__':
output = my_flow()Zanie
.submit and a for loop instead of .mapChristian Juhl
11/14/2022, 4:34 PMZanie
with_options.Zanie
map.Christian Juhl
11/14/2022, 4:41 PMwith_options ?Zanie
new_task = square_number.with_options(tags="foo") then later do new_task() or new_task.submit() . with_numbers does not know it is going to be chained with map so there’s not much we can do there for mapping-specific behavior.Christian Juhl
11/14/2022, 4:56 PMmap