run_dbt_cloud_job to trigger a job run and wait until the job run is finished. If some nodes fail, run_dbt_cloud_job can efficiently retry the unsuccessful nodes. Prior to running this flow, save your dbt Cloud credentials to a DbtCloudCredentials block and create a DbtCloudJob block.
Before creating blocks for the first time, register
prefect-dbt’s block types:Save dbt Cloud credentials to a block
Blocks can be created through code or through the UI. To create a dbt Cloud Credentials block:- Log into your dbt Cloud account.
- Click API Tokens on the sidebar.
- Copy a Service Token.
- Copy the account ID from the URL:
https://cloud.getdbt.com/settings/accounts/<ACCOUNT_ID>. - Create and run the following script, replacing the placeholders:
Create a dbt Cloud job block
- In dbt Cloud, click on Deploy -> Jobs.
- Select a job.
- Copy the job ID from the URL:
https://cloud.getdbt.com/deploy/<ACCOUNT_ID>/projects/<PROJECT_ID>/jobs/<JOB_ID> - Create and run the following script, replacing the placeholders.
Run a dbt Cloud job and wait for completion
See also
- SDK reference — full
prefect_dbt.cloudAPI.