Leon Kozlowski
04/15/2023, 3:45 AMtrigger_dbt_cli_command
pre-built task?Ryan Peden
04/15/2023, 4:24 AMfrom prefect import flow, tags, task
from prefect_dbt import trigger_dbt_cli_command
@flow
def my_flow():
with tags("a", "b"):
trigger_dbt_cli_command("dbt build",) # has tags: a, b
and with_options
, which is useful if you want to define a retagged version of a task you can use in several different places:
from prefect import flow, task
from prefect_dbt import trigger_dbt_cli_command
dbt_project_1_cmd = trigger_dbt_cli_command.with_options(tags=["project_1"])
dbt_project_2_cmd = trigger_dbt_cli_command.with_options(tags=["project_2"])
@flow
def my_flow():
dbt_project_1_cmd("dbt build", project_dir="/home/me/project_1")
# do other things with project 1
dbt_project_1_cmd("dbt clean", project_dir="/home/me/project_1")
dbt_project_2_cmd("dbt build", project_dir="/home/me/project_2")
# do other things with project 2
dbt_project_2_cmd("dbt clean", project_dir="/home/me/project_2")
I'm not sure if the examples I chose for with_options
make complete sense for dbt, but I hope they give an idea of why you might want to tag your dbt tasks with with_options
vs. the context manager.