prefect_dbt.cloud.jobs
Module containing tasks and flows for interacting with dbt Cloud jobs
Functions
get_dbt_cloud_job_info
dbt_cloud_credentials: Credentials for authenticating with dbt Cloud.job_id: The ID of the job to get.
- The job data returned by the dbt Cloud administrative API.
create_dbt_cloud_job
dbt_cloud_credentials: Credentials for authenticating with dbt Cloud.project_id: The ID of the project to create the job in.environment_id: The ID of the environment for the job.name: The name of the job.execute_steps: List of dbt commands to execute (e.g. [“dbt run”, “dbt test”]). Defaults to [“dbt build”].**kwargs: Additional job configuration options.
- The job data returned by the dbt Cloud administrative API.
delete_dbt_cloud_job
dbt_cloud_credentials: Credentials for authenticating with dbt Cloud.job_id: The ID of the job to delete.
trigger_dbt_cloud_job_run
dbt_cloud_credentials: Credentials for authenticating with dbt Cloud.job_id: The ID of the job to trigger.options: An optional TriggerJobRunOptions instance to specify overrides for the triggered job run.
- The run data returned from the dbt Cloud administrative API.
get_run_id
trigger_dbt_cloud_job_run task and downstream tasks/flows that use the run ID.
Args:
obj: The JSON body from the trigger job run response.
trigger_dbt_cloud_job_run_and_wait_for_completion
dbt_cloud_credentials: Credentials for authenticating with dbt Cloud.job_id: The ID of the job to trigger.trigger_job_run_options: An optional TriggerJobRunOptions instance to specify overrides for the triggered job run.max_wait_seconds: Maximum number of seconds to wait for job to completepoll_frequency_seconds: Number of seconds to wait in between checks for run completion.retry_filtered_models_attempts: Number of times to retry models selected byretry_status_filters.
DbtCloudJobRunCancelled: The triggered dbt Cloud job run was cancelled.DbtCloudJobRunFailed: The triggered dbt Cloud job run failed.RuntimeError: The triggered dbt Cloud job run ended in an unexpected state.
- The run data returned by the dbt Cloud administrative API.
retry_dbt_cloud_job_run_subset_and_wait_for_completion
dbt_cloud_credentials: Credentials for authenticating with dbt Cloud.trigger_job_run_options: An optional TriggerJobRunOptions instance to specify overrides for the triggered job run.max_wait_seconds: Maximum number of seconds to wait for job to completepoll_frequency_seconds: Number of seconds to wait in between checks for run completion.run_id: The ID of the job run to retry.
ValueError: Iftrigger_job_run_options.steps_overrideis set by the user.
- The run data returned by the dbt Cloud administrative API.
run_dbt_cloud_job
dbt_cloud_job: Block that holds the information and methods to interact with a dbt Cloud job.targeted_retries: The number of times to retry failed steps.
Classes
DbtCloudJobRun
Class that holds the information and methods to interact
with the resulting run of a dbt Cloud job.
Methods:
fetch_result
step: The index of the step in the run to query for artifacts. The first step in the run has the index 1. If the step parameter is omitted, then this method will return the artifacts compiled for the last step in the run.
get_run
- The run data.
get_run_artifacts
path: The relative path to the run artifact.step: The index of the step in the run to query for artifacts. The first step in the run has the index 1. If the step parameter is omitted, then this method will return the artifacts compiled for the last step in the run.
- The contents of the requested manifest. Returns a
Dictif the requested artifact is a JSON file and astrotherwise.
get_status_code
- The run status code.
retry_failed_steps
- A representation of the dbt Cloud job run.
wait_for_completion
DbtCloudJob
Block that holds the information and methods to interact with a dbt Cloud job.
Attributes:
dbt_cloud_credentials: The credentials to use to authenticate with dbt Cloud.job_id: The id of the dbt Cloud job.timeout_seconds: The number of seconds to wait for the job to complete.interval_seconds: The number of seconds to wait between polling for job completion.trigger_job_run_options: The options to use when triggering a job run.
get_job
order_by: The field to order the results by.
- The job data.
trigger
- A representation of the dbt Cloud job run.