Kiley Roberson
10/03/2023, 10:50 PMmy_task.map([value1, value2])
where the task run is called My task: {value1}
?Marvin
10/03/2023, 10:50 PM.map()
implementation that automatically creates a task run for each element of its input data. Mapped tasks represent the computations of many individual children tasks. The simplest Prefect map takes a tasks and applies it to each element of its inputs.
Here's a basic example:
python
from prefect import flow, task
@task
def print_nums(nums):
for n in nums:
print(n)
@task
def square_num(num):
return num**2
@flow
def map_flow(nums):
print_nums(nums)
squared_nums = square_num.map(nums)
print_nums(squared_nums)
map_flow([1,2,3,5,8,13])
In this example, the square_num
task is mapped over the list of numbers, creating a separate task run for each number.
As for dynamic task names, Prefect tasks can return various types of data, including strings which could be used for dynamic naming. However, the task name is typically defined at task creation and isn't designed to be dynamic per run.
If you want to track different runs of a task with different parameters, you might consider using Prefect's logging features or task tags to add dynamic information to your tasks.
Remember, I'm a robot and this is based on my understanding of the documents. You might want to check the official Prefect documentation for more accurate information.