Skip to content

Commit

Permalink
Change formatting order, rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke committed Sep 20, 2024
1 parent 3a42c72 commit 53ee509
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 6 additions & 2 deletions core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ def safe_run_hooks(
started_at = datetime.utcnow()
ordered_hooks = self.get_hooks_by_type(hook_type)

if hook_type == RunHookType.End and ordered_hooks:
fire_event(Formatting(""))

# on-run-* hooks should run outside a transaction. This happens because psycopg2 automatically begins a transaction when a connection is created.
adapter.clear_transaction()
if not ordered_hooks:
Expand All @@ -541,8 +544,6 @@ def safe_run_hooks(
failed = False
num_hooks = len(ordered_hooks)

fire_event(Formatting(""))

for idx, hook in enumerate(ordered_hooks, 1):
with log_contextvars(node_info=hook.node_info):
hook.index = idx
Expand Down Expand Up @@ -605,6 +606,9 @@ def safe_run_hooks(
)
)

if hook_type == RunHookType.Start and ordered_hooks:
fire_event(Formatting(""))

return status

def print_results_line(self, results, execution_time) -> None:
Expand Down
11 changes: 5 additions & 6 deletions core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,19 @@ def print_results_line(self, node_results, elapsed):
def execute_with_hooks(self, selected_uids: AbstractSet[str]):
adapter = get_adapter(self.config)

fire_event(Formatting(""))
fire_event(
ConcurrencyLine(
num_threads=self.config.threads,
target_name=self.config.target_name,
node_count=self.num_nodes,
)
)
fire_event(Formatting(""))

self.started_at = time.time()
try:
before_run_status = self.before_run(adapter, selected_uids)
fire_event(Formatting(""))

if before_run_status == RunStatus.Success or (
not get_flags().skip_nodes_if_on_run_start_fails
Expand All @@ -531,9 +532,9 @@ def execute_with_hooks(self, selected_uids: AbstractSet[str]):
node_info=node.node_info,
)
)
skipped_node = mark_node_as_skipped(node, executed_node_ids, None)
if skipped_node:
self.node_results.append(skipped_node)
skipped_node_result = mark_node_as_skipped(node, executed_node_ids, None)
if skipped_node_result:
self.node_results.append(skipped_node_result)

self.after_run(adapter, res)
finally:
Expand Down Expand Up @@ -561,15 +562,13 @@ def run(self):
)

if len(self._flattened_nodes) == 0:
fire_event(Formatting(""))
warn_or_error(NothingToDo())
result = self.get_result(
results=[],
generated_at=datetime.utcnow(),
elapsed_time=0.0,
)
else:
fire_event(Formatting(""))
selected_uids = frozenset(n.unique_id for n in self._flattened_nodes)
result = self.execute_with_hooks(selected_uids)

Expand Down

0 comments on commit 53ee509

Please sign in to comment.