Steven Schmatz
09/05/2023, 8:08 PMdbt run --vars '{"key": "value"}'
Sorry for the basic question - I for some reason haven’t been able to find this in the docs.from prefect import flow
from prefect_dbt.cloud import DbtCloudCredentials
from prefect_dbt.cloud import DbtCloudJob
from prefect_dbt.cloud.models import TriggerJobRunOptions
from <http://prefect_dbt.cloud.jobs|prefect_dbt.cloud.jobs> import trigger_dbt_cloud_job_run_and_wait_for_completion
@flow(log_prints=True)
def trigger_dbt():
dbt_cloud_job = DbtCloudJob.load('dbt-cloud-job-run-all-models')
dbt_cloud_credentials = DbtCloudCredentials.load('dbt-cloud-credentials')
run_result = trigger_dbt_cloud_job_run_and_wait_for_completion(
dbt_cloud_credentials=dbt_cloud_credentials,
job_id=dbt_cloud_job.job_id
)
print(run_result)
trigger_dbt()
steps_override
was the key
from prefect import flow
from prefect_dbt.cloud import DbtCloudCredentials
from prefect_dbt.cloud import DbtCloudJob
from prefect_dbt.cloud.models import TriggerJobRunOptions
from <http://prefect_dbt.cloud.jobs|prefect_dbt.cloud.jobs> import trigger_dbt_cloud_job_run_and_wait_for_completion
@flow(log_prints=True)
def trigger_dbt():
dbt_cloud_job = DbtCloudJob.load('dbt-cloud-job-run-all-models')
dbt_cloud_credentials = DbtCloudCredentials.load('dbt-cloud-credentials')
run_result = trigger_dbt_cloud_job_run_and_wait_for_completion(
dbt_cloud_credentials=dbt_cloud_credentials,
job_id=dbt_cloud_job.job_id,
trigger_job_run_options=TriggerJobRunOptions(
steps_override=[
"""dbt build --vars '{\"example_variable\": 1234}'"""
],
),
)
print(run_result)
trigger_dbt()
Nate
09/06/2023, 12:39 AM