Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire skipped events at debug level #10244

Merged
merged 9 commits into from
Jun 6, 2024
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240113-073615.yaml
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 9 additions & 4 deletions core/dbt/task/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,14 +69,13 @@


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(""))

Check warning on line 78 in core/dbt/task/printer.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/printer.py#L77-L78

Added lines #L77 - L78 were not covered by tests
if is_warning:
fire_event(
RunResultWarning(
Expand Down Expand Up @@ -112,8 +112,13 @@
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)

Check warning on line 118 in core/dbt/task/printer.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/printer.py#L116-L118

Added lines #L116 - L118 were not covered by tests
elif result.message is not None:
if newline:
fire_event(Formatting(""))
fire_event(RunResultError(msg=result.message, node_info=node_info))


Expand Down
32 changes: 32 additions & 0 deletions tests/functional/minimal_cli/test_minimal_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
Loading