Hello, currently migrating from prefect v1 to v2 a...
# ask-community
a
Hello, currently migrating from prefect v1 to v2 and I'm trying to find the way of passing this argument to a generic task as I was doing it on v1. Is it possible on v2?
Copy code
task_args={"name": "current-task-run-name"}
c
This should be an option I think unless I misunderstand your question - https://docs.prefect.io/api-ref/prefect/tasks/ Task_run_name is a field
a
Yeah, I've seen this, but I try adding the task_run_name parameter when calling the task and I get:
got an unexpected keyword argument 'task_run_name'.
c
How are you setting it? It’s in the object, so that’s surprising. https://github.com/PrefectHQ/prefect/blob/main/src/prefect/tasks.py#L176
a
yeah, I know, I've been through the code too 😕 I just add
task_run_name="task_name"
as a parameter to the task
c
Have you tried using it like:
@task(task_run_name="task_name")
or is that what you mean?
a
no, what I'm trying to do is the following. I define a task:
Copy code
@task(name="generic-task-name")
def task_a(name: str):
    print(f"Hello {name}")
and then call it withing the flow like this:
Copy code
@flow(name="Amazing-flow")
def my_flow():
    task_a("Andres",task_run_name="task-to-say-hello-to-andres")
this was possible on lower versions of prefect afaik
@Christopher Boyd is the above possible?
c
Without explicitly testing it myself, I don’t know . Looking at the error you’re receiving, it’s because
task_a(name: str)
does not have
task_run_name
defined, so you’re passing an argument that only exists in the wrapper