diff --git a/.changes/unreleased/Fixes-20240113-073615.yaml b/.changes/unreleased/Fixes-20240113-073615.yaml new file mode 100644 index 00000000000..3dd68508db8 --- /dev/null +++ b/.changes/unreleased/Fixes-20240113-073615.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Convert "Skipping model due to fail_fast" message to DEBUG level +time: 2024-01-13T07:36:15.836294-00:00 +custom: + Author: scottgigante,nevdelap + Issue: "8774" diff --git a/core/dbt/task/printer.py b/core/dbt/task/printer.py index 953a967b4a2..7bedbfaba93 100644 --- a/core/dbt/task/printer.py +++ b/core/dbt/task/printer.py @@ -13,6 +13,7 @@ StatsLine, ) from dbt.node_types import NodeType +from dbt_common.events.base_types import EventLevel from dbt_common.events.format import pluralize from dbt_common.events.functions import fire_event from dbt_common.events.types import Formatting @@ -68,14 +69,13 @@ def print_run_status_line(results) -> None: def print_run_result_error(result, newline: bool = True, is_warning: bool = False) -> None: - if newline: - fire_event(Formatting("")) - # set node_info for logging events node_info = None if hasattr(result, "node") and result.node: node_info = result.node.node_info if result.status == NodeStatus.Fail or (is_warning and result.status == NodeStatus.Warn): + if newline: + fire_event(Formatting("")) if is_warning: fire_event( RunResultWarning( @@ -112,8 +112,13 @@ def print_run_result_error(result, newline: bool = True, is_warning: bool = Fals fire_event( CheckNodeTestFailure(relation_name=result.node.relation_name, node_info=node_info) ) - + elif result.status == NodeStatus.Skipped and result.message is not None: + if newline: + fire_event(Formatting(""), level=EventLevel.DEBUG) + fire_event(RunResultError(msg=result.message), level=EventLevel.DEBUG) elif result.message is not None: + if newline: + fire_event(Formatting("")) fire_event(RunResultError(msg=result.message, node_info=node_info)) diff --git a/tests/functional/minimal_cli/test_minimal_cli.py b/tests/functional/minimal_cli/test_minimal_cli.py index d47f8b911c5..c757b43d4b3 100644 --- a/tests/functional/minimal_cli/test_minimal_cli.py +++ b/tests/functional/minimal_cli/test_minimal_cli.py @@ -53,6 +53,38 @@ def test_build(self, runner, project): assert "SKIP=1" in result.output +class TestBuildFailFast(BaseConfigProject): + def test_build(self, runner, project): + runner.invoke(cli, ["deps"]) + result = runner.invoke(cli, ["build", "--fail-fast"]) + # 1 seed, 1 model, 2 data tests + assert "PASS=4" in result.output + # 2 data tests + assert "ERROR=2" in result.output + # Singular test + assert "WARN=1" in result.output + # 1 snapshot + assert "SKIP=1" in result.output + # Skipping due to fail_fast is not shown when --debug is not specified. + assert "Skipping due to fail_fast" not in result.output + + +class TestBuildFailFastDebug(BaseConfigProject): + def test_build(self, runner, project): + runner.invoke(cli, ["deps"]) + result = runner.invoke(cli, ["build", "--fail-fast", "--debug"]) + # 1 seed, 1 model, 2 data tests + assert "PASS=4" in result.output + # 2 data tests + assert "ERROR=2" in result.output + # Singular test + assert "WARN=1" in result.output + # 1 snapshot + assert "SKIP=1" in result.output + # Skipping due to fail_fast is shown when --debug is specified. + assert "Skipping due to fail_fast" in result.output + + class TestDocsGenerate(BaseConfigProject): def test_docs_generate(self, runner, project): runner.invoke(cli, ["deps"])