Skip to content

Commit

Permalink
replace logger.warning with warn_or_error
Browse files Browse the repository at this point in the history
Uses `warn_or_error` to log _or_ raise errors depending on arguments
passed.
  • Loading branch information
Jesse Lax committed Oct 7, 2021
1 parent b501f43 commit 62f775a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Add generic tests defined on sources to the manifest once, not twice ([#3347](https:/dbt-labs/dbt/issues/3347), [#3880](https:/dbt-labs/dbt/pull/3880))
- Skip partial parsing if certain macros have changed ([#3810](https:/dbt-labs/dbt/issues/3810), [#3982](https:/dbt-labs/dbt/pull/3892))
- Enable cataloging of unlogged Postgres tables ([3961](https:/dbt-labs/dbt/issues/3961), [#3993](https:/dbt-labs/dbt/pull/3993))
- Return an error instead of a warning when runing with `--warn-error` and no models are selected ([#4006](https:/dbt-labs/dbt/issues/4006), [#4019](https:/dbt-labs/dbt/pull/4019))

### Under the hood

Expand All @@ -34,6 +35,7 @@ Contributors:
- [@dave-connors-3](https:/dave-connors-3) ([#3920](https:/dbt-labs/dbt/issues/3920))
- [@kadero](https:/kadero) ([#3952](https:/dbt-labs/dbt/issues/3952))
- [@samlader](https:/samlader) ([#3993](https:/dbt-labs/dbt/pull/3993))
- [@laxjesse](https:/laxjesse) ([#4019](https:/dbt-labs/dbt/pull/4019))

## dbt 0.21.0 (October 04, 2021)

Expand Down
6 changes: 3 additions & 3 deletions core/dbt/task/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from dbt.task.runnable import GraphRunnableTask, ManifestTask
from dbt.task.test import TestSelector
from dbt.node_types import NodeType
from dbt.exceptions import RuntimeException, InternalException
from dbt.logger import log_manager, GLOBAL_LOGGER as logger
from dbt.exceptions import RuntimeException, InternalException, warn_or_error
from dbt.logger import log_manager


class ListTask(GraphRunnableTask):
Expand Down Expand Up @@ -61,7 +61,7 @@ def _iterate_selected_nodes(self):
spec = self.get_selection_spec()
nodes = sorted(selector.get_selected(spec))
if not nodes:
logger.warning('No nodes selected!')
warn_or_error('No nodes selected!')
return
if self.manifest is None:
raise InternalException(
Expand Down
5 changes: 3 additions & 2 deletions core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
NotImplementedException,
RuntimeException,
FailFastException,
warn_or_error,
)

from dbt.graph import (
Expand Down Expand Up @@ -438,8 +439,8 @@ def run(self):
)

if len(self._flattened_nodes) == 0:
logger.warning("\nWARNING: Nothing to do. Try checking your model "
"configs and model specification args")
warn_or_error("\nWARNING: Nothing to do. Try checking your model "
"configs and model specification args")
result = self.get_result(
results=[],
generated_at=datetime.utcnow(),
Expand Down

0 comments on commit 62f775a

Please sign in to comment.