Skip to content

Commit

Permalink
Merge pull request #2579 from christineberger/feature/change_yml_warn…
Browse files Browse the repository at this point in the history
…ing_color

Feature: Change project-level warning color
  • Loading branch information
beckjake authored Jun 22, 2020
2 parents 8f649f5 + fbfb54e commit f758614
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


### Features
- Made project-level warnings more apparent ([#2545](https:/fishtown-analytics/dbt/issues/2545))
- Added a `full_refresh` config item that overrides the behavior of the `--full-refresh` flag ([#1009](https:/fishtown-analytics/dbt/issues/1009), [#2348](https:/fishtown-analytics/dbt/pull/2348))
- Added a "docs" field to macros, with a "show" subfield to allow for hiding macros from the documentation site ([#2430](https:/fishtown-analytics/dbt/issues/2430))
- Added intersection syntax for model selector ([#2167](https:/fishtown-analytics/dbt/issues/2167), [#2417](https:/fishtown-analytics/dbt/pull/2417))
Expand Down
8 changes: 5 additions & 3 deletions core/dbt/config/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def warn_for_unused_resource_config_paths(
len(unused),
'\n'.join('- {}'.format('.'.join(u)) for u in unused)
)
warn_or_error(msg, log_fmt=printer.yellow('{}'))

warn_or_error(msg, log_fmt=printer.warning_tag('{}'))

def load_dependencies(self) -> Mapping[str, 'RuntimeConfig']:
if self.dependencies is None:
Expand Down Expand Up @@ -549,9 +550,10 @@ def from_args(cls: Type[RuntimeConfig], args: Any) -> 'RuntimeConfig':


UNUSED_RESOURCE_CONFIGURATION_PATH_MESSAGE = """\
WARNING: Configuration paths exist in your dbt_project.yml file which do not \
Configuration paths exist in your dbt_project.yml file which do not \
apply to any resources.
There are {} unused configuration paths:\n{}
There are {} unused configuration paths:
{}
"""


Expand Down
1 change: 1 addition & 0 deletions core/dbt/deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class DbtProjectYamlDeprecation(DBTDeprecation):
For upgrading instructions, consult the documentation:
https://docs.getdbt.com/docs/guides/migration-guide/upgrading-to-0-17-0
'''


Expand Down
10 changes: 7 additions & 3 deletions core/dbt/ui/printer.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import textwrap
import time
from typing import Dict, Optional, Tuple

from dbt.logger import GLOBAL_LOGGER as logger, DbtStatusMessage, TextOnly
from dbt.node_types import NodeType
from dbt.tracking import InvocationProcessor
import dbt.ui.colors


USE_COLORS = False

COLOR_FG_RED = dbt.ui.colors.COLORS['red']
Expand Down Expand Up @@ -368,6 +365,9 @@ def print_end_of_run_summary(


def print_run_end_messages(results, keyboard_interrupt: bool = False) -> None:
# Prevent import loop from happening by importing tracking here.
from dbt.tracking import InvocationProcessor # noqa

errors = [r for r in results if r.error is not None or r.fail]
warnings = [r for r in results if r.warn]
with DbtStatusMessage(), InvocationProcessor():
Expand Down Expand Up @@ -404,3 +404,7 @@ def line_wrap_message(
splitter = '\r\n\r\n' if '\r\n\r\n' in msg else '\n\n'
chunks = msg.split(splitter)
return '\n'.join(textwrap.fill(chunk, width=width) for chunk in chunks)


def warning_tag(msg: str) -> str:
return f'[{yellow("WARNING")}]: {msg}'
17 changes: 12 additions & 5 deletions core/dbt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.node_types import NodeType
from dbt.clients import yaml_helper
from dbt.ui import printer

DECIMALS: Tuple[Type[Any], ...]
try:
Expand Down Expand Up @@ -300,15 +301,18 @@ def __get__(self, obj, objtype):

def invalid_ref_fail_unless_test(node, target_model_name,
target_model_package, disabled):

if node.resource_type == NodeType.Test:
msg = dbt.exceptions.get_target_not_found_or_disabled_msg(
node, target_model_name, target_model_package, disabled
)
if disabled:
logger.debug(f'WARNING: {msg}')
logger.debug(printer.warning_tag(msg))
else:
dbt.exceptions.warn_or_error(msg, log_fmt='WARNING: {}')

dbt.exceptions.warn_or_error(
msg,
log_fmt=printer.warning_tag('{}')
)
else:
dbt.exceptions.ref_target_not_found(
node,
Expand All @@ -326,9 +330,12 @@ def invalid_source_fail_unless_test(
node, target_name, target_table_name, disabled
)
if disabled:
logger.debug(f'WARNING: {msg}')
logger.debug(printer.warning_tag(msg))
else:
dbt.exceptions.warn_or_error(msg, log_fmt='WARNING: {}')
dbt.exceptions.warn_or_error(
msg,
log_fmt=printer.warning_tag('{}')
)
else:
dbt.exceptions.source_target_not_found(
node,
Expand Down

0 comments on commit f758614

Please sign in to comment.