Skip to content

Commit

Permalink
Reimplement ui.warning_tag to centralize logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 committed Dec 2, 2021
1 parent f0a3be5 commit 3ec5f65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,10 +960,9 @@ def parse_patch(
unique_id = f'macro.{patch.package_name}.{patch.name}'
macro = self.manifest.macros.get(unique_id)
if not macro:
warn_or_error(
f'WARNING: Found patch for macro "{patch.name}" '
f'which was not found'
)
msg = f'Found patch for macro "{patch.name}" ' \
f'which was not found'
warn_or_error(msg, log_fmt=warning_tag('{}'))
return
if macro.patch_path:
package_name, existing_file_path = macro.patch_path.split('://')
Expand Down
6 changes: 4 additions & 2 deletions core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import dbt.exceptions
from dbt import flags
import dbt.utils
from dbt.ui import warning_tag

RESULT_FILE_NAME = 'run_results.json'
MANIFEST_FILE_NAME = 'manifest.json'
Expand Down Expand Up @@ -461,8 +462,9 @@ def run(self):
if len(self._flattened_nodes) == 0:
with TextOnly():
fire_event(EmptyLine())
warn_or_error("WARNING: Nothing to do. Try checking your model "
"configs and model specification args")
msg = "Nothing to do. Try checking your model " \
"configs and model specification args"
warn_or_error(msg, log_fmt=warning_tag('{}'))
result = self.get_result(
results=[],
generated_at=datetime.utcnow(),
Expand Down
4 changes: 1 addition & 3 deletions core/dbt/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,4 @@ def line_wrap_message(


def warning_tag(msg: str) -> str:
# no longer needed, since new logging includes colorized log level
# return f'[{yellow("WARNING")}]: {msg}'
return msg
return f'[{yellow("WARNING")}]: {msg}'

0 comments on commit 3ec5f65

Please sign in to comment.