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

[Backport 1.4.latest] Call update_event_status earlier + rename an event #6591

Merged
merged 1 commit into from
Jan 13, 2023
Merged
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-20230111-134058.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Call update_event_status earlier for node results. Rename event 'HookFinished' -> FinishedRunningStats
time: 2023-01-11T13:40:58.577722+01:00
custom:
Author: jtcohen6
Issue: "6571"
6 changes: 3 additions & 3 deletions core/dbt/events/proto_types.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions core/dbt/events/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -747,15 +747,15 @@ message HooksRunningMsg {
}

// E047
message HookFinished {
message FinishedRunningStats {
string stat_line = 1;
string execution = 2;
float execution_time = 3;
}

message HookFinishedMsg {
message FinishedRunningStatsMsg {
EventInfo info = 1;
HookFinished data = 2;
FinishedRunningStats data = 2;
}


Expand Down
2 changes: 1 addition & 1 deletion core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ def message(self) -> str:


@dataclass
class HookFinished(InfoLevel, pt.HookFinished):
class FinishedRunningStats(InfoLevel, pt.FinishedRunningStats):
def code(self):
return "E047"

Expand Down
7 changes: 7 additions & 0 deletions core/dbt/task/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import traceback
from abc import ABCMeta, abstractmethod
from typing import Type, Union, Dict, Any, Optional
from datetime import datetime

from dbt import tracking
from dbt import flags
Expand Down Expand Up @@ -208,6 +209,9 @@ def run_with_hooks(self, manifest):
self.before_execute()

result = self.safe_run(manifest)
self.node.update_event_status(
node_status=result.status, finished_at=datetime.utcnow().isoformat()
)

if not self.node.is_ephemeral_model:
self.after_execute(result)
Expand Down Expand Up @@ -448,6 +452,9 @@ def on_skip(self):
)
)
else:
# 'skipped' nodes should not have a value for 'node_finished_at'
# they do have 'node_started_at', which is set in GraphRunnableTask.call_runner
self.node.update_event_status(node_status=RunStatus.Skipped)
fire_event(
SkippingDetails(
resource_type=self.node.resource_type,
Expand Down
6 changes: 4 additions & 2 deletions core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
DatabaseErrorRunningHook,
EmptyLine,
HooksRunning,
HookFinished,
FinishedRunningStats,
LogModelResult,
LogStartLine,
LogHookEndLine,
Expand Down Expand Up @@ -421,7 +421,9 @@ def print_results_line(self, results, execution_time):
with TextOnly():
fire_event(EmptyLine())
fire_event(
HookFinished(stat_line=stat_line, execution=execution, execution_time=execution_time)
FinishedRunningStats(
stat_line=stat_line, execution=execution, execution_time=execution_time
)
)

def before_run(self, adapter, selected_uids: AbstractSet[str]):
Expand Down
4 changes: 0 additions & 4 deletions core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ def call_runner(self, runner):
status: Dict[str, str] = {}
try:
result = runner.run_with_hooks(self.manifest)
status = runner.get_result_status(result)
runner.node.update_event_status(
node_status=result.status, finished_at=datetime.utcnow().isoformat()
)
finally:
finishctx = TimestampNamed("finished_at")
with finishctx, DbtModelState(status):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_event_codes(self):
BuildingCatalog(),
DatabaseErrorRunningHook(hook_type=""),
HooksRunning(num_hooks=0, hook_type=""),
HookFinished(stat_line="", execution="", execution_time=0),
FinishedRunningStats(stat_line="", execution="", execution_time=0),

# I - Project parsing ======================
ParseCmdOut(msg="testing"),
Expand Down