From 73c11064ce12a89f8ba086f21bf2786e8702a491 Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Fri, 11 Oct 2024 16:29:44 +0100 Subject: [PATCH] Fix node_status for hooks --- core/dbt/task/run.py | 2 ++ core/dbt/task/runnable.py | 2 +- tests/functional/adapter/hooks/test_on_run_hooks.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py index 93a8e261b50..e168f2080d9 100644 --- a/core/dbt/task/run.py +++ b/core/dbt/task/run.py @@ -669,6 +669,8 @@ def safe_run_hooks( status = RunStatus.Skipped message = f"{hook_name} skipped" + hook.update_event_status(node_status=status) + self.node_results.append( RunResult( status=status, diff --git a/core/dbt/task/runnable.py b/core/dbt/task/runnable.py index a37308f81ea..304b5e2f7be 100644 --- a/core/dbt/task/runnable.py +++ b/core/dbt/task/runnable.py @@ -266,7 +266,7 @@ def call_runner(self, runner: BaseRunner) -> RunResult: # `_event_status` dict is only used for logging. Make sure # it gets deleted when we're done with it - runner.node.clear_event_status() + # runner.node.clear_event_status() fail_fast = get_flags().FAIL_FAST diff --git a/tests/functional/adapter/hooks/test_on_run_hooks.py b/tests/functional/adapter/hooks/test_on_run_hooks.py index ffb34c3f23a..9ba1e45c299 100644 --- a/tests/functional/adapter/hooks/test_on_run_hooks.py +++ b/tests/functional/adapter/hooks/test_on_run_hooks.py @@ -49,6 +49,9 @@ def test_results(self, project, log_counts, my_model_run_status): ] assert [(result.node.unique_id, result.status) for result in results] == expected_results + assert [ + (result.node.unique_id, result.node.node_info["node_status"]) for result in results + ] == [(id, str(status)) for id, status in expected_results] assert log_counts in log_output assert "4 project hooks, 1 view model" in log_output