Skip to content

Commit

Permalink
updates associated with merging main
Browse files Browse the repository at this point in the history
- removed 3 new log call sites and replaced with structured logs
- removed 2 unused struc logs
  • Loading branch information
emmyoop committed Nov 8, 2021
1 parent 0ad6cb1 commit 66cece0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 41 deletions.
51 changes: 21 additions & 30 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,34 +295,6 @@ def cli_msg(self) -> str:
return f"command return code={self.code}"


@dataclass
class SelectorAlertUpto3UnusedNodes(InfoLevel, CliEventABC):
node_names: List[str]

def cli_msg(self) -> str:
summary_nodes_str = ("\n - ").join(self.node_names[:3])
and_more_str = (
f"\n - and {len(self.node_names) - 3} more" if len(self.node_names) > 4 else ""
)
return (
f"\nSome tests were excluded because at least one parent is not selected. "
f"Use the --greedy flag to include them."
f"\n - {summary_nodes_str}{and_more_str}"
)


@dataclass
class SelectorAlertAllUnusedNodes(DebugLevel, CliEventABC):
node_names: List[str]

def cli_msg(self) -> str:
debug_nodes_str = ("\n - ").join(self.node_names)
return (
f"Full list of tests that were excluded:"
f"\n - {debug_nodes_str}"
)


@dataclass
class SelectorReportInvalidSelector(InfoLevel, CliEventABC):
selector_methods: dict
Expand Down Expand Up @@ -728,6 +700,16 @@ def cli_msg(self) -> str:
return f"Partial parsing: deleted exposure {self.unique_id}"


class PartialParsingProjectEnvVarsChanged(InfoLevel, CliEventABC):
def cli_msg(self) -> str:
return "Unable to do partial parsing because env vars used in dbt_project.yml have changed"


class PartialParsingProfileEnvVarsChanged(InfoLevel, CliEventABC):
def cli_msg(self) -> str:
return "Unable to do partial parsing because env vars used in profiles.yml have changed"


@dataclass
class InvalidDisabledSourceInTestNode(WarnLevel, CliEventABC):
msg: str
Expand Down Expand Up @@ -1767,6 +1749,14 @@ def cli_msg(self) -> str:
return str(self.exc)


@dataclass
class SQlRunnerException(ShowException, DebugLevel, CliEventABC):
exc: Exception

def cli_msg(self) -> str:
return f"Got an exception: {self.exc}"


# since mypy doesn't run on every file we need to suggest to mypy that every
# class gets instantiated. But we don't actually want to run this code.
# making the conditional `if False` causes mypy to skip it as dead code so
Expand Down Expand Up @@ -1803,8 +1793,6 @@ def cli_msg(self) -> str:
SystemStdOutMsg(bmsg=b'')
SystemStdErrMsg(bmsg=b'')
SystemReportReturnCode(code=0)
SelectorAlertUpto3UnusedNodes(node_names=[])
SelectorAlertAllUnusedNodes(node_names=[])
SelectorReportInvalidSelector(selector_methods={'': ''}, spec_method='', raw_spec='')
MacroEventInfo(msg='')
MacroEventDebug(msg='')
Expand Down Expand Up @@ -1849,6 +1837,8 @@ def cli_msg(self) -> str:
PartialParsingUpdateSchemaFile(file_id='')
PartialParsingDeletedSource(unique_id='')
PartialParsingDeletedExposure(unique_id='')
PartialParsingProjectEnvVarsChanged()
PartialParsingProfileEnvVarsChanged()
InvalidDisabledSourceInTestNode(msg='')
InvalidRefInTestNode(msg='')
MessageHandleGenericException(build_path='', unique_id='', exc=Exception(''))
Expand Down Expand Up @@ -1959,3 +1949,4 @@ def cli_msg(self) -> str:
RetryExternalCall(attempt=0, max=0)
GeneralWarningMsg(msg='', log_fmt='')
GeneralWarningException(exc=Exception(''), log_fmt='')
SQlRunnerException(exc=Exception(''))
4 changes: 1 addition & 3 deletions core/dbt/graph/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from .selector_spec import SelectionCriteria, SelectionSpec

from dbt.events.functions import fire_event
from dbt.events.types import (
SelectorAlertUpto3UnusedNodes, SelectorAlertAllUnusedNodes, SelectorReportInvalidSelector
)
from dbt.events.types import SelectorReportInvalidSelector
from dbt.node_types import NodeType
from dbt.exceptions import (
InternalException,
Expand Down
11 changes: 5 additions & 6 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
PartialParsingFailedBecauseConfigChange, PartialParsingFailedBecauseProfileChange,
PartialParsingFailedBecauseNewProjectDependency, PartialParsingFailedBecauseHashChanged,
PartialParsingNotEnabled, ParsedFileLoadFailed, PartialParseSaveFileNotFound,
InvalidDisabledSourceInTestNode, InvalidRefInTestNode
InvalidDisabledSourceInTestNode, InvalidRefInTestNode, PartialParsingProjectEnvVarsChanged,
PartialParsingProfileEnvVarsChanged
)
from dbt.logger import DbtProcessState
from dbt.node_types import NodeType
Expand Down Expand Up @@ -276,7 +277,7 @@ def load(self):
file_dict = source_file.to_dict()
fire_event(PartialParsingFile(file_dict=file_dict))
exc_info['parse_file_type'] = parse_file_type
fire_event(PartialParsingException())
fire_event(PartialParsingException(exc_info=exc_info))

# Send event
if dbt.tracking.active_user is not None:
Expand Down Expand Up @@ -564,14 +565,12 @@ def is_partial_parsable(self, manifest: Manifest) -> Tuple[bool, Optional[str]]:
reparse_reason = ReparseReason.profile_changed
if self.manifest.state_check.project_env_vars_hash != \
manifest.state_check.project_env_vars_hash:
logger.info("Unable to do partial parsing because env vars "
"used in dbt_project.yml have changed")
fire_event(PartialParsingProjectEnvVarsChanged())
valid = False
reparse_reason = ReparseReason.proj_env_vars_changed
if self.manifest.state_check.profile_env_vars_hash != \
manifest.state_check.profile_env_vars_hash:
logger.info("Unable to do partial parsing because env vars "
"used in profiles.yml have changed")
fire_event(PartialParsingProfileEnvVarsChanged())
valid = False
reparse_reason = ReparseReason.prof_env_vars_changed

Expand Down
5 changes: 3 additions & 2 deletions core/dbt/task/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
RemoteRunResult,
ResultTable,
)
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.events.functions import fire_event
from dbt.events.types import SQlRunnerException
from dbt.task.compile import CompileRunner


Expand All @@ -23,7 +24,7 @@ def __init__(self, config, adapter, node, node_index, num_nodes):
)

def handle_exception(self, e, ctx):
logger.debug('Got an exception: {}'.format(e), exc_info=True)
fire_event(SQlRunnerException(exc=e))
if isinstance(e, dbt.exceptions.Exception):
if isinstance(e, dbt.exceptions.RuntimeException):
e.add_node(ctx.node)
Expand Down

0 comments on commit 66cece0

Please sign in to comment.