Hi all, is there any function that I can use to ge...
# ask-community
a
Hi all, is there any function that I can use to get the current task name dynamically? something like:
Copy code
@task
def mytask():
    task_name = prefect.get_task_name()
j
Check out the Runtime Context.
Copy code
from prefect import flow, task
from prefect import runtime

@flow(log_prints=True)
def my_flow(x):
    print("My name is", runtime.flow_run.name)
    print("I belong to deployment", runtime.deployment.name)
    my_task(2)

@task
def my_task(y):
    print("My name is", runtime.task_run.name)
    print("Flow run parameters:", runtime.flow_run.parameters)

my_flow(1)
a
I will take a look thanks!
👍 1