Koen
02/11/2025, 8:11 AMMarvin
02/11/2025, 8:11 AMtask_run_name
argument when defining your task. Python's standard string formatting syntax applies, allowing you to dynamically generate the name using variables or context information.
Here's a basic example:
python
from prefect import task
@task(name="My Task")
def my_task():
return "Hello, world!"
# You can also use a function to set the task run name
@task(task_run_name=lambda: f"My Task Run: {prefect.runtime.task_run_id}")
def my_dynamic_task():
return "Hello, dynamic world!"
In this example, task_run_name
can be a static string or a lambda function that returns a string. You can access runtime information using prefect.runtime
to make the name more dynamic.
For more details, you can refer to the Prefect task writing documentation.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