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 3fa7bbc
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 171 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 LogStartBatch {
NodeInfo node_info = 1;
string description = 2;
int32 batch_index = 3;
int32 total_batches = 4;
}

message LogStartBatchMsg {
CoreEventInfo info = 1;
LogStartBatch 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
350 changes: 179 additions & 171 deletions core/dbt/events/core_types_pb2.py

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,51 @@ 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}"

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

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1718

Added line #L1718 was not covered by tests

# TODO update common so that we can append "batch" in `format_fancy_output_line`
formatted = format_fancy_output_line(

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

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1721

Added line #L1721 was not covered by tests
msg=msg,
status="RUN",
index=self.batch_index,
total=self.total_batches,
)
return f"Batch {formatted}"

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

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1727

Added line #L1727 was not covered by tests


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

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

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1732

Added line #L1732 was not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L1742 - L1743 were not covered by tests

msg = f"{info} {self.description}"

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

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1745

Added line #L1745 was not covered by tests

# TODO update common so that we can append "batch" in `format_fancy_output_line`
formatted = format_fancy_output_line(

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

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1748

Added line #L1748 was not covered by tests
msg=msg,
status=status,
index=self.batch_index,
total=self.total_batches,
execution_time=self.execution_time,
)
return f"Batch {formatted}"

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

View check run for this annotation

Codecov / codecov/patch

core/dbt/events/types.py#L1755

Added line #L1755 was not covered by tests


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

0 comments on commit 3fa7bbc

Please sign in to comment.