feat: add job run logs retrieval to DbtCloudHook and enhance logging in DbtCloudRunJobOperator #46946
+82
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several enhancements to the
dbt
Cloud provider in Airflow, focusing on improving the logging and monitoring of job runs. The most important changes include adding a new method to retrieve job run logs, modifying the execution process to stream logs in real-time, and updating theexecute_complete
method to log final job run logs.Enhancements to logging and monitoring:
providers/dbt/cloud/src/airflow/providers/dbt/cloud/hooks/dbt.py
: Added theget_job_run_logs
method to retrieve logs for a specific run of a dbt Cloud job.providers/dbt/cloud/src/airflow/providers/dbt/cloud/operators/dbt.py
: Modified theexecute
method to stream logs for job runs in real-time, providing better visibility into the job's progress.providers/dbt/cloud/src/airflow/providers/dbt/cloud/operators/dbt.py
: Updated theexecute_complete
method to log the final logs for job runs, ensuring that the complete log history is captured.<!--Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.This pull request introduces new functionality to stream and log job run outputs for dbt Cloud jobs in Airflow, as well as some minor documentation improvements. The most important changes include adding a method to retrieve job run logs, modifying the execution flow to stream logs during job runs, and updating the
execute_complete
method to log final job run outputs.New functionality for logging and streaming:
providers/dbt/cloud/src/airflow/providers/dbt/cloud/hooks/dbt.py
: Added a new methodget_job_run_logs
to retrieve logs for a specific run of a dbt Cloud job.providers/dbt/cloud/src/airflow/providers/dbt/cloud/operators/dbt.py
: Modified theexecute
method to stream logs during the job run and check the job status in a loop until it reaches a terminal state.Documentation improvements:
providers/dbt/cloud/src/airflow/providers/dbt/cloud/operators/dbt.py
: Added a docstring to theexecute_complete
method to provide details about its parameters and return value.These changes enhance the monitoring capabilities for dbt Cloud jobs by providing real-time log streaming and better visibility into job execution status.