Charles Leung
04/02/2024, 11:58 PMNate
04/03/2024, 12:07 AMwith_options like this
In [1]: from prefect import flow, task
In [2]: @task
...: def foo():
...: pass
...:
In [3]: @flow
...: def bar():
...: foo.with_options(tags={"special-tag"})()Charles Leung
04/03/2024, 3:54 PMCharles Leung
04/03/2024, 3:54 PMNate
04/03/2024, 4:01 PMwith_options is just a @classmethod that allows you the pass those decorator kwargs in again (after defining it), which is espcially helpful when you want to customize a task definition based on runtime data (e.g. set tags for a task based on inputs for a flow)
for certain decorator kwargs (result_storage_key, task_run_name etc) , we make the parameters of the task templatable like you tried first but we don't do that for tags as far as I knowCharles Leung
04/03/2024, 4:25 PM._with_options() is that it now does not rename my task name and keeps it as the name of the function (async_query). This is how I'm invoking the task within my flow:Nate
04/03/2024, 4:27 PMtask_name to name your prefect task, you could just remove task_name as a kwarg of our task and just pass name="1_data_wait..." to with_options along with tagsCharles Leung
04/03/2024, 6:42 PMCharles Leung
04/03/2024, 6:42 PMNate
04/03/2024, 6:42 PM