Adrien Besnard
06/22/2026, 4:13 PMMarvin
06/22/2026, 4:13 PMMarvin
06/22/2026, 4:14 PMtask_run_name= on the @task decorator.
For a task parameter, the simplest pattern is:
python
from prefect import task
@task(task_run_name="process-{customer_id}")
def process_customer(customer_id: str):
...
If you call:
python
process_customer("abc-123")
the task run name will be process-abc-123.
Recommended approach
- Use a string template when the name is just based on task parameters
- Use a callable if you need more logic
Example with a callable:
python
from prefect import task
def make_name(parameters):
return f"process-{parameters['customer_id']}"
@task(task_run_name=make_name)
def process_customer(customer_id: str):
...
A couple of notes:
- task_run_name names the task run, not the task definition itself
- The template uses task function parameters, so {customer_id} must match the argument name exactly
- This is the most idiomatic Prefect 3.x solution
Docs/code-backed behavior from Prefect 3.x: task_run_name supports either a string template or a callable.
If you want, I can also show the equivalent pattern for flow run names using flow_run_name=.Adrien Besnard
06/22/2026, 6:47 PMAdrien Besnard
06/22/2026, 6:47 PMMarvin
06/22/2026, 6:47 PMMarvin
06/22/2026, 6:48 PMpython
from prefect import flow
@flow(flow_run_name="etl-{dataset}")
def etl(dataset: str):
...
etl("customers")
That creates a flow run named etl-customers.
And together with a task:
python
from prefect import flow, task
@task(task_run_name="extract-{table}")
def extract(table: str):
...
@flow(flow_run_name="pipeline-{table}")
def pipeline(table: str):
extract(table)
pipeline("orders")
This gives you:
- flow run name: pipeline-orders
- task run name: extract-orders
If you need more complex naming logic, flow_run_name can also be a callable, similar to task_run_name.
Relevant docs/source-backed behavior:
- Prefect supports dynamic task_run_name and flow_run_name via templates/callables in 3.x
- Prefect docs: https://docs.prefect.io/
If you'd like, I can give you the exact pattern for your task signature.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by