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

Fix plural of "partial success" #11002

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241114-170328.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix plural of 'partial success' in log message
time: 2024-11-14T17:03:28.888232+01:00
custom:
Author: jtcohen6
Issue: "10999"
2 changes: 1 addition & 1 deletion core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ def code(self) -> str:
def message(self) -> str:
error_plural = pluralize(self.num_errors, "error")
warn_plural = pluralize(self.num_warnings, "warning")
partial_success_plural = pluralize(self.num_partial_success, "partial success")
partial_success_plural = f"""{self.num_partial_success} partial {"success" if self.num_partial_success == 1 else "successes"}"""

if self.keyboard_interrupt:
message = yellow("Exited because of keyboard interrupt")
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/microbatch/test_microbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def test_run_with_event_time(self, project):

assert "PARTIAL SUCCESS" not in console_output
assert "ERROR" in console_output
assert "Completed with 1 error, 0 partial successs, and 0 warnings" in console_output
assert "Completed with 1 error, 0 partial successes, and 0 warnings" in console_output

self.assert_row_count(project, "microbatch_model", 2)

Expand All @@ -612,7 +612,7 @@ def test_run_with_event_time(self, project):

assert "PARTIAL SUCCESS" not in console_output
assert "ERROR" in console_output
assert "Completed with 1 error, 0 partial successs, and 0 warnings" in console_output
assert "Completed with 1 error, 0 partial successes, and 0 warnings" in console_output

self.assert_row_count(project, "microbatch_model", 2)

Expand Down
32 changes: 23 additions & 9 deletions tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
TestLevel,
WarnLevel,
)
from dbt.events.types import RunResultError
from dbt.task.printer import print_run_result_error
from dbt.task.printer import print_run_end_messages
from dbt_common.events import types
from dbt_common.events.base_types import msg_from_base_event
from dbt_common.events.event_manager import EventManager, TestEventManager
Expand Down Expand Up @@ -553,23 +552,38 @@ def test_single_run_error():
event_mgr = TestEventManager()
ctx_set_event_manager(event_mgr)

class MockNode:
unique_id: str = ""
node_info = None

error_result = RunResult(
status=RunStatus.Error,
timing=[],
thread_id="",
execution_time=0.0,
node=None,
node=MockNode(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print_run_end_messages() expects this result to have an actual node object, with a unique_id value and a node_info key

adapter_response=dict(),
message="oh no!",
failures=1,
batch_results=None,
)

print_run_result_error(error_result)
events = [e for e in event_mgr.event_history if isinstance(e[0], RunResultError)]

assert len(events) == 1
assert events[0][0].msg == "oh no!"
results = [error_result]
print_run_end_messages(results)
events = [e for e in event_mgr.event_history]

summary_event = [
e for e in event_mgr.event_history if isinstance(e[0], core_types.EndOfRunSummary)
]
run_result_error_events = [
e for e in event_mgr.event_history if isinstance(e[0], core_types.RunResultError)
]

# expect correct plural
assert "partial successes" in summary_event[0][0].message()

# expect one error to show up
assert len(run_result_error_events) == 1
assert run_result_error_events[0][0].msg == "oh no!"

finally:
# Set an empty event manager unconditionally on exit. This is an early
Expand Down
Loading