Blocks Catalog
Below is a list of Blocks available for registration in
prefect-dbt
.
To register blocks in this module to view and edit them on Prefect Cloud, first install the required packages, then
prefect block register -m prefect_dbt
load
method on Blocks, you must already have a block document saved through code or saved through the UI.
Cloud.Credentials Module
Credentials block for credential use across dbt Cloud tasks and flows.
To load the DbtCloudCredentials:
from prefect import flow
from prefect_dbt.cloud.credentials import DbtCloudCredentials
@flow
def my_flow():
my_block = DbtCloudCredentials.load("MY_BLOCK_NAME")
my_flow()
Cloud.Jobs Module
Block that holds the information and methods to interact with a dbt Cloud job.
To load the DbtCloudJob:
from prefect import flow
from prefect_dbt.cloud.jobs import DbtCloudJob
@flow
def my_flow():
my_block = DbtCloudJob.load("MY_BLOCK_NAME")
my_flow()
Cli.Configs.Base Module
Target configs contain credentials and settings, specific to the warehouse you're connecting to. To find valid keys, head to the Available adapters page and click the desired adapter's "Profile Setup" hyperlink.
To load the TargetConfigs:
from prefect import flow
from prefect_dbt.cli.configs.base import TargetConfigs
@flow
def my_flow():
my_block = TargetConfigs.load("MY_BLOCK_NAME")
my_flow()
Global configs control things like the visual output of logs, the manner in which dbt parses your project, and what to do when dbt finds a version mismatch or a failing model. Docs can be found here.
To load the GlobalConfigs:
from prefect import flow
from prefect_dbt.cli.configs.base import GlobalConfigs
@flow
def my_flow():
my_block = GlobalConfigs.load("MY_BLOCK_NAME")
my_flow()
Cli.Configs.Snowflake Module
Target configs contain credentials and settings, specific to Snowflake. To find valid keys, head to the Snowflake Profile page.
To load the SnowflakeTargetConfigs:
from prefect import flow
from prefect_dbt.cli.configs.snowflake import SnowflakeTargetConfigs
@flow
def my_flow():
my_block = SnowflakeTargetConfigs.load("MY_BLOCK_NAME")
my_flow()
Cli.Configs.Bigquery Module
dbt CLI target configs containing credentials and settings, specific to BigQuery.
To load the BigQueryTargetConfigs:
from prefect import flow
from prefect_dbt.cli.configs.bigquery import BigQueryTargetConfigs
@flow
def my_flow():
my_block = BigQueryTargetConfigs.load("MY_BLOCK_NAME")
my_flow()
Cli.Configs.Postgres Module
dbt CLI target configs containing credentials and settings specific to Postgres.
To load the PostgresTargetConfigs:
from prefect import flow
from prefect_dbt.cli.configs.postgres import PostgresTargetConfigs
@flow
def my_flow():
my_block = PostgresTargetConfigs.load("MY_BLOCK_NAME")
my_flow()
Cli.Credentials Module
Profile for use across dbt CLI tasks and flows.
To load the DbtCliProfile:
from prefect import flow
from prefect_dbt.cli.credentials import DbtCliProfile
@flow
def my_flow():
my_block = DbtCliProfile.load("MY_BLOCK_NAME")
my_flow()
Cli.Commands Module
A block representing a dbt operation, containing multiple dbt and shell commands.
For long-lasting operations, use the trigger method and utilize the block as a context manager for automatic closure of processes when context is exited. If not, manually call the close method to close processes.
For short-lasting operations, use the run method. Context is automatically managed with this method.
To load the DbtCoreOperation:
from prefect import flow
from prefect_dbt.cli.commands import DbtCoreOperation
@flow
def my_flow():
my_block = DbtCoreOperation.load("MY_BLOCK_NAME")
my_flow()