https://prefect.io logo
a

Asterios Pantousas

07/27/2023, 3:41 PM
Subject: Request for Assistance with Task Naming in Prefect UI for dbt Models Hello everyone👋, hope you are doing well! I am writing to discuss an issue we are experiencing with our use of Prefect and dbt in our current project. Within our Prefect flow, we utilize multiple tasks through the
trigger_dbt_cli_command
, each performing various CLI commands. More specifically, we run different dbt models based on certain tags. The issue we encounter is within the Prefect UI, where these dbt tasks are automatically assigned default names (such as
trigger_dbt_cli_command-0
,
trigger_dbt_cli_command-1
, etc.). This automatic naming becomes problematic when a task fails, as it is difficult to discern precisely which task has encountered the error. From the docs I didn't manage to find any solution to that. We would greatly appreciate your insight and any potential solutions to this naming issue. 😁
n

Nate

07/27/2023, 4:28 PM
hi @Asterios Pantousas - you could use
.with_options
along with the runtime templating here to do something like
Copy code
from prefect import flow, task
from prefect_dbt.cli.commands import trigger_dbt_cli_command

trigger_dbt = trigger_dbt_cli_command.with_options(task_run_name="Run {command}")

@flow
def foo():
   trigger_dbt(command="dbt debug")

if __name__ == "__main__":
   foo()
Task run 'Run dbt debug'
a

Asterios Pantousas

07/27/2023, 6:57 PM
That's very helpful @Nate, it is exactly what I was searching for! Thanks a lot! 🙏
n

Nate

07/27/2023, 6:58 PM
👍