Skip to main content

prefect_dbt.core.runner

Runner for dbt commands

Functions

execute_dbt_node

execute_dbt_node(task_state: NodeTaskTracker, node_id: str, asset_id: Union[str, None])
Execute a dbt node and wait for its completion. This function will:
  1. Set up the task logger
  2. Wait for the node to finish using efficient threading.Event
  3. Check the node’s status and fail if it’s in a failure state

Classes

PrefectDbtRunner

A runner for executing dbt commands with Prefect integration. This class enables the invocation of dbt commands while integrating with Prefect’s logging and assets capabilities. Args:
  • manifest: Optional pre-loaded dbt manifest
  • settings: Optional PrefectDbtSettings instance for configuring dbt
  • raise_on_failure: Whether to raise an error if the dbt command encounters a non-exception failure
  • client: Optional Prefect client instance
  • include_compiled_code: Whether to include compiled code in the asset description
  • disable_assets: Global override for disabling asset generation for dbt nodes. If True, assets will not be created for any dbt nodes, even if the node’s prefect config has enable_assets set to True.
  • _force_nodes_as_tasks: Whether to force each dbt node execution to have a Prefect task representation when .invoke() is called outside of a flow or task run
Methods:

get_dbt_event_msg

get_dbt_event_msg(event: EventMsg) -> str

graph

graph(self) -> Graph

invoke

invoke(self, args: list[str], **kwargs: Any)
Invokes a dbt command. Supports the same arguments as dbtRunner.invoke(). https://docs.getdbt.com/reference/programmatic-invocations Args:
  • args: List of command line arguments
  • **kwargs: Additional keyword arguments
Returns:
  • The result of the dbt command invocation

log_level

log_level(self) -> EventLevel

manifest

manifest(self) -> Manifest

profiles_dir

profiles_dir(self) -> Path

project_dir

project_dir(self) -> Path

project_name

project_name(self) -> str

target_path

target_path(self) -> Path