Skip to content

Commit

Permalink
Change specific to release 1.1.2 - to be reverted after #561 is closed
Browse files Browse the repository at this point in the history
(cherry picked from commit 1483fd4)
  • Loading branch information
tatiana committed Sep 27, 2023
1 parent e44138d commit 2a28ef1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cosmos/operators/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
)
from cosmos.dbt.parser.output import extract_log_issues, parse_output

logger = get_logger(__name__)
DBT_NO_TESTS_MSG = "Nothing to do"
DBT_WARN_MSG = "WARN"

logger = get_logger(__name__)

try:
from airflow.providers.openlineage.extractors.base import OperatorLineage
Expand Down Expand Up @@ -473,12 +475,18 @@ def _handle_warnings(self, result: FullOutputSubprocessResult, context: Context)
warning_context["test_names"] = test_names
warning_context["test_results"] = test_results

if self.on_warning_callback:
self.on_warning_callback(warning_context)
self.on_warning_callback and self.on_warning_callback(warning_context)

def execute(self, context: Context) -> None:
result = self.build_and_run_cmd(context=context)
if self.on_warning_callback and "WARN" in result.output:
should_trigger_callback = all(
[
self.on_warning_callback,
DBT_NO_TESTS_MSG not in result.output,
DBT_WARN_MSG in result.output,
]
)
if should_trigger_callback:
warnings = parse_output(result, "WARN")
if warnings > 0:
self._handle_warnings(result, context)
Expand Down

0 comments on commit 2a28ef1

Please sign in to comment.