From 2c7541b9742c6bd2f4e75ecffc0d591bbb547b6b Mon Sep 17 00:00:00 2001 From: Scott Gigante Date: Sat, 13 Jan 2024 18:00:11 +1030 Subject: [PATCH 1/5] Fire skipped events at debug level Closes https://github.com/dbt-labs/dbt-core/issues/8774 --- core/dbt/task/printer.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/dbt/task/printer.py b/core/dbt/task/printer.py index a05e4089676..6e8ed419375 100644 --- a/core/dbt/task/printer.py +++ b/core/dbt/task/printer.py @@ -5,6 +5,7 @@ ) from dbt.common.events.functions import fire_event from dbt.common.events.types import Formatting +from dbt.events.base_types import EventLevel from dbt.events.types import ( RunResultWarning, RunResultWarningMessage, @@ -75,11 +76,10 @@ def print_run_status_line(results) -> None: def print_run_result_error(result, newline: bool = True, is_warning: bool = False) -> None: - if newline: - with TextOnly(): - fire_event(Formatting("")) - if result.status == NodeStatus.Fail or (is_warning and result.status == NodeStatus.Warn): + if newline: + with TextOnly(): + fire_event(Formatting("")) if is_warning: fire_event( RunResultWarning( @@ -115,7 +115,16 @@ def print_run_result_error(result, newline: bool = True, is_warning: bool = Fals fire_event(Formatting("")) fire_event(CheckNodeTestFailure(relation_name=result.node.relation_name)) + elif result.status == NodeStatus.Skipped and result.message is not None: + if newline: + with TextOnly(): + fire_event(Formatting(""), level=EventLevel.DEBUG) + fire_event(RunResultError(msg=result.message), level=EventLevel.DEBUG) + elif result.message is not None: + if newline: + with TextOnly(): + fire_event(Formatting("")) fire_event(RunResultError(msg=result.message)) From edbd4c54060df1aa085b137d73105904a01102ab Mon Sep 17 00:00:00 2001 From: Scott Gigante Date: Sat, 13 Jan 2024 18:08:06 +1030 Subject: [PATCH 2/5] add changelog entry --- .changes/unreleased/Fixes-20240113-073615.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixes-20240113-073615.yaml diff --git a/.changes/unreleased/Fixes-20240113-073615.yaml b/.changes/unreleased/Fixes-20240113-073615.yaml new file mode 100644 index 00000000000..3472fa4292d --- /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 + Issue: "8774" From d3da59e6eaea90176334669829297fb49103a4d0 Mon Sep 17 00:00:00 2001 From: Nev Delap Date: Thu, 30 May 2024 13:15:41 +1000 Subject: [PATCH 3/5] Update to work with 1.9.*. --- core/dbt/task/printer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/task/printer.py b/core/dbt/task/printer.py index abf74e40e58..7bedbfaba93 100644 --- a/core/dbt/task/printer.py +++ b/core/dbt/task/printer.py @@ -12,8 +12,8 @@ SQLCompiledPath, StatsLine, ) -from dbt.events.base_types import EventLevel 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 From 7566cb2349ad24b23ba1582a8a90e0c32dedf8cb Mon Sep 17 00:00:00 2001 From: Nev Delap Date: Tue, 4 Jun 2024 09:26:48 +1000 Subject: [PATCH 4/5] Add tests for --fail-fast not showing skip messages unless --debug. --- .../minimal_cli/test_minimal_cli.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/functional/minimal_cli/test_minimal_cli.py b/tests/functional/minimal_cli/test_minimal_cli.py index d47f8b911c5..066eef09cac 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 result.output.count("Skipping due to fail_fast") == 1 + + class TestDocsGenerate(BaseConfigProject): def test_docs_generate(self, runner, project): runner.invoke(cli, ["deps"]) From 55a6a63203cebe94e31082ec054f7ca4e0ff87f8 Mon Sep 17 00:00:00 2001 From: Nev Delap Date: Wed, 5 Jun 2024 10:08:33 +1000 Subject: [PATCH 5/5] Update test that works byitself, but assumes to much to work in integration tests. --- tests/functional/minimal_cli/test_minimal_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/minimal_cli/test_minimal_cli.py b/tests/functional/minimal_cli/test_minimal_cli.py index 066eef09cac..c757b43d4b3 100644 --- a/tests/functional/minimal_cli/test_minimal_cli.py +++ b/tests/functional/minimal_cli/test_minimal_cli.py @@ -82,7 +82,7 @@ def test_build(self, runner, project): # 1 snapshot assert "SKIP=1" in result.output # Skipping due to fail_fast is shown when --debug is specified. - assert result.output.count("Skipping due to fail_fast") == 1 + assert "Skipping due to fail_fast" in result.output class TestDocsGenerate(BaseConfigProject):