Skip to content

Commit

Permalink
Reuse the dbt list approach when the --quiet flag is used
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 committed Apr 16, 2024
1 parent 91e501e commit 15b94ce
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
23 changes: 15 additions & 8 deletions core/dbt/task/compile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import threading

from dbt.flags import get_flags
from dbt.artifacts.schemas.run import RunStatus, RunResult
from dbt_common.events.base_types import EventLevel
from dbt_common.events.functions import fire_event
Expand Down Expand Up @@ -89,16 +90,22 @@ def task_end_messages(self, results):
matched_results = []

for result in matched_results:
fire_event(
CompiledNode(
node_name=result.node.name,
compiled=result.node.compiled_code,
is_inline=is_inline,
output_format=output_format,
unique_id=result.node.unique_id,
)

compiled_node_event = CompiledNode(
node_name=result.node.name,
compiled=result.node.compiled_code,
is_inline=is_inline,
output_format=output_format,
unique_id=result.node.unique_id,
quiet=get_flags().QUIET,
)

if get_flags().LOG_FORMAT == "json":
fire_event(compiled_node_event)
else:
# Cleaner to leave as print than to mutate the logger not to print timestamps.
print(compiled_node_event.message())

def _runtime_initialize(self):
if getattr(self.args, "inline", None):
try:
Expand Down
22 changes: 14 additions & 8 deletions core/dbt/task/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import threading
import time

from dbt.flags import get_flags
from dbt.context.providers import generate_runtime_model_context
from dbt.contracts.graph.nodes import SeedNode
from dbt.artifacts.schemas.run import RunResult, RunStatus
Expand Down Expand Up @@ -98,16 +99,21 @@ def task_end_messages(self, results):
if hasattr(result.node, "version") and result.node.version:
node_name += f".v{result.node.version}"

fire_event(
ShowNode(
node_name=node_name,
preview=output.getvalue(),
is_inline=is_inline,
output_format=self.args.output,
unique_id=result.node.unique_id,
)
show_node_event = ShowNode(
node_name=node_name,
preview=output.getvalue(),
is_inline=is_inline,
output_format=self.args.output,
unique_id=result.node.unique_id,
quiet=get_flags().QUIET,
)

if get_flags().LOG_FORMAT == "json":
fire_event(show_node_event)
else:
# Cleaner to leave as print than to mutate the logger not to print timestamps.
print(show_node_event.message())

def _handle_result(self, result):
super()._handle_result(result)

Expand Down

0 comments on commit 15b94ce

Please sign in to comment.