Zivile
05/15/2024, 11:44 AMtask.map
definition in prefect code?Marvin
05/15/2024, 11:44 AMtask.map
definition and usage in Prefect can be found in the Prefect documentation under the section about tasks. The documentation describes .map()
as an implementation that automatically creates a task run for each element of its input data. Mapped tasks represent the computations of many individual children tasks.
Here is a direct link to the relevant section of the documentation: Tasks - Map
And a brief example of its usage:
python
from prefect import flow, task
@task
def square_num(num):
return num**2
@flow
def map_flow(nums):
squared_nums = square_num.map(nums)
#... rest of your flow
You can see more examples and explanations in the provided link.