If you have an existing dbt Cloud job, use the pre-built flowDocumentation Index
Fetch the complete documentation index at: https://docs.prefect.io/llms.txt
Use this file to discover all available pages before exploring further.
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
Create Prefect assets from a dbt Cloud job
Setcreate_assets=True to emit Prefect asset materializations for the dbt models, seeds, and snapshots that completed successfully in the dbt Cloud run.
Assets are created from the run’s dbt artifacts, so the dbt Cloud job must make manifest.json and run_results.json available.
See also
- SDK reference — full
prefect_dbt.cloudAPI.