https://prefect.io logo
#best-practices
Title
# best-practices
m

Max Jackson

06/07/2022, 8:51 PM
hello all! what’s the best way to pass a Prefect keyword to a new Task class? I want to do something like
Copy code
@task(key=value)
within a structure like
Copy code
class MyNewTask(Task): 
    def run():
         pass
where would I pass those key/value pairs when initializing the new capital-T Task?
k

Kevin Kho

06/07/2022, 8:58 PM
You can try
Copy code
mnt = MyNewTask(key=value)

with Flow(..) as flow:
    mnt()
If that doesn’t work, look at this task from the task library. Specifically, note how
**kwargs
is passed to
super.init()
. You might need this in your Task definition I think. Or it might just work.
m

Max Jackson

06/07/2022, 9:00 PM
fantastic, thank you! 🙌
11 Views