Bharat Khaneja
02/07/2025, 3:27 PMMarvin
02/07/2025, 3:27 PMtask_run_name
parameter with Python's standard string formatting syntax. This allows you to distinguish runs of the same task by providing a unique name for each execution.
Here's a basic example:
python
from prefect import task, flow
from prefect.runtime import context
@task(task_run_name=lambda: f"dynamic_name_{context.task_run_id}")
def my_task():
print("Executing task")
@flow
def my_flow():
for _ in range(3):
my_task()
my_flow()
In this example, the task name will include the task run ID, making each execution unique.
For more detailed information, you can explore the Prefect documentation on writing tasks.
If you have further requirements or need additional help, feel free to ask.Bharat Khaneja
02/10/2025, 2:23 PMMarvin
02/10/2025, 2:23 PMtask_run_name
function. Here's how you can do it:
python
from prefect import task, flow
@task(task_run_name=lambda x: f"task_with_{x}")
def my_task(x):
print(f"Executing task with {x}")
@flow
def my_flow():
for i in range(3):
my_task(i)
my_flow()
In this example, the task name will include the value of x
, which is passed as a parameter to the task. This way, each task run will have a unique name based on the parameter value.