From 5e9d3d6bf5f7ad139d24e3e21421f7837550284f Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Tue, 29 Oct 2024 10:26:21 -0500 Subject: [PATCH] Delay calculation of `failures` in `safe_run_hooks` to simplify code If it isn't apparent, I'm trying to reduce the need for tracking variables to make it easier extract the execution code to a separate private function to make it easier to see what is happening. --- core/dbt/task/run.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py index 6a83f7a4ece..df6afdfa797 100644 --- a/core/dbt/task/run.py +++ b/core/dbt/task/run.py @@ -653,7 +653,6 @@ def safe_run_hooks( hook_name = f"{hook.package_name}.{hook_type}.{hook.index - 1}" execution_time = 0.0 timing: List[TimingInfo] = [] - failures = 1 if status == RunStatus.Success: with collect_timing_info("compile", timing.append): @@ -681,7 +680,6 @@ def safe_run_hooks( finished_at = timing[1].completed_at or datetime.utcnow() hook.update_event_status(finished_at=finished_at.isoformat()) execution_time = (finished_at - started_at).total_seconds() - failures = 0 if status == RunStatus.Success else 1 if status == RunStatus.Success: message = f"{hook_name} passed" @@ -701,7 +699,7 @@ def safe_run_hooks( message=message, adapter_response={}, execution_time=execution_time, - failures=failures, + failures=0 if status == RunStatus.Success else 1, node=hook, ) )