Skip to content

Commit

Permalink
Add two new event types LogStartBatch and LogBatchResult
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm committed Dec 7, 2024
1 parent 0c16d07 commit 670d907
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
29 changes: 29 additions & 0 deletions core/dbt/events/core_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,35 @@ message MicrobatchExecutionDebugMsg {
MicrobatchExecutionDebug data = 2;
}

// Q045
message LogBatchLine {
NodeInfo node_info = 1;
string description = 2;
int32 batch_index = 3;
int32 total_batches = 4;
}

message LogStartBatchMsg {
CoreEventInfo info = 1;
LogBatchLine data = 2;
}

// Q046
message LogBatchResult {
NodeInfo node_info = 1;
string description = 2;
string status = 3;
int32 batch_index = 4;
int32 total_batches = 5;
float execution_time = 6;
Group group = 7;
}

message LogBatchResultMsg {
CoreEventInfo info = 1;
LogBatchResult data = 2;
}

// W - Node testing

// Skipped W001
Expand Down
41 changes: 41 additions & 0 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,47 @@ def message(self) -> str:
return self.msg


class LogStartBatch(InfoLevel):
def code(self) -> str:
return "Q045"

Check warning on line 1715 in core/dbt/events/types.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1715

Added line #L1715 was not covered by tests

def message(self) -> str:
msg = f"START {self.description}"
return format_fancy_output_line(

Check warning on line 1719 in core/dbt/events/types.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1718-L1719

Added lines #L1718 - L1719 were not covered by tests
msg=msg,
status="RUN",
index=self.batch_index,
total=self.total_batches,
progress_prefix="Batch",
)


class LogBatchResult(DynamicLevel):
def code(self) -> str:
return "Q046"

Check warning on line 1730 in core/dbt/events/types.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1730

Added line #L1730 was not covered by tests

def message(self) -> str:
if self.status == "error":
info = "ERROR creating"
status = red(self.status.upper())
elif "SKIP" in self.status:
info = "SKIPPED"
status = yellow(self.status.upper())

Check warning on line 1738 in core/dbt/events/types.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1733-L1738

Added lines #L1733 - L1738 were not covered by tests
else:
info = "OK created"
status = green(self.status)

Check warning on line 1741 in core/dbt/events/types.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1740-L1741

Added lines #L1740 - L1741 were not covered by tests

msg = f"{info} {self.description}"
return format_fancy_output_line(

Check warning on line 1744 in core/dbt/events/types.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1743-L1744

Added lines #L1743 - L1744 were not covered by tests
msg=msg,
status=status,
index=self.batch_index,
total=self.total_batches,
execution_time=self.execution_time,
progress_prefix="Batch",
)


# =======================================================
# W - Node testing
# =======================================================
Expand Down

0 comments on commit 670d907

Please sign in to comment.