Skip to content

Commit

Permalink
add msg directly during object creation
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke committed Jan 8, 2025
1 parent 11c42b9 commit 3c4e191
Show file tree
Hide file tree
Showing 5 changed files with 299 additions and 328 deletions.
2 changes: 1 addition & 1 deletion core/dbt/events/core_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ message LogNodeResult {
int32 index = 4;
int32 total = 5;
float execution_time = 6;
map<string, string> status_to_message_map = 7;
string msg = 7;
}

message LogNodeResultMsg {
Expand Down
588 changes: 292 additions & 296 deletions core/dbt/events/core_types_pb2.py

Large diffs are not rendered by default.

23 changes: 1 addition & 22 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,28 +1347,7 @@ def code(self) -> str:
return "Q008"

def message(self) -> str:
for status in self.status_to_message_map:
if self.status == status:
return self.status_to_message_map[status]

# Catch-all, we should never be here
return red(
f"Unknown status for {self.node_info.resource_type} '{self.node_info.unique_id}'"
)

@classmethod
def status_to_level(cls, status):
level_lookup = {
"success": EventLevel.INFO,
"no-op": EventLevel.INFO,
"error": EventLevel.ERROR,
"skipped": EventLevel.WARN,
"partial success": EventLevel.WARN,
}
if status in level_lookup:
return level_lookup[status]
else:
return EventLevel.INFO
return self.msg


# Skipped Q009, Q010
Expand Down
12 changes: 4 additions & 8 deletions tests/unit/events/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,15 @@ def test_dynamic_level_events():
assert msg.info.level == "info"


def test_log_node_level():
def test_log_node_result():
event = LogNodeResult(
node_info={},
status="error",
index=1,
total=0,
status_to_message_map={
"error": "red(error message)",
"skipped": "yellow(skipped message)",
"success": "green(success message)",
},
msg="some message",
)
msg = msg_from_base_event(event, level=LogNodeResult.status_to_level(event.status))
msg = msg_from_base_event(event, level=EventLevel.ERROR)
assert msg
assert msg.info.msg == "red(error message)"
assert msg.info.msg == "some message"
assert msg.info.level == "error"
2 changes: 1 addition & 1 deletion tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def test_event_codes(self):
index=0,
total=0,
execution_time=0,
status_to_message_map={},
msg="",
),
core_types.LogStartLine(description="", index=0, total=0),
core_types.LogModelResult(
Expand Down

0 comments on commit 3c4e191

Please sign in to comment.