Is there any nice way to modify the arguments give...
# prefect-community
s
Is there any nice way to modify the arguments given in the
@task
decorator after that task has been defined? Say I use a task from a collection that and want to use a custom
cache_key_fn
. It looks like i could do it by
Copy code
from copy import copy
from some_collection import some_task
some_task_cache = copy(some_task)
some_task_cache.cache_key_fn = my_cache_fn
but that seems a bit hacky. The actual problem is the other way around - I want to provide a collection for users, but they would want to modify the task decorator arguments.
m
Hey @Stefan Rasmussen Assuming this is for prefect 2 you can do this using the with_options method available on any task function https://docs.prefect.io/api-ref/prefect/tasks/#prefect.tasks.Task.with_options. I'm not sure if this is available for prefect 1 as best I can tell it's not
s
Thanks! Exactly what I need. Yes, it's for Prefect 2. Maybe it would make sense to put in the Task section of the docs? The Task arguments section only mentions using the decorator