-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a print Event to replace the print usage in dbt-core #130
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
dbt_common/events/logger.py
Outdated
@@ -120,7 +122,11 @@ def create_line(self, msg: EventMsg) -> str: | |||
def write_line(self, msg: EventMsg): | |||
line = self.create_line(msg) | |||
if self._python_logger is not None: | |||
send_to_logger(self._python_logger, msg.info.level, line) | |||
if isinstance(msg.data, PrintEvent): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterallenwebb This is a draft to help me understand some way of achieving the goal. Let's discuss Monday and see what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related PR dbt-labs/dbt-core#10131
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the best way to achieve what we want, the only drawback is we can not have core inherent this event and define new ones since the proto namespace will change.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #130 +/- ##
==========================================
+ Coverage 56.37% 56.66% +0.28%
==========================================
Files 50 50
Lines 3090 3106 +16
==========================================
+ Hits 1742 1760 +18
+ Misses 1348 1346 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
"category": "", | ||
"code": "Z052", | ||
"extra": {}, | ||
"level": "info", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterallenwebb level is expected
@@ -120,7 +122,11 @@ def create_line(self, msg: EventMsg) -> str: | |||
def write_line(self, msg: EventMsg): | |||
line = self.create_line(msg) | |||
if self._python_logger is not None: | |||
send_to_logger(self._python_logger, msg.info.level, line) | |||
if isinstance(msg.data, PrintEvent): | |||
level = "error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following why this happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to make sure the PrintEvent still makes it to stdout even when quiet is specified. Let me add a comment since it is not obvious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
dbt_common/events/logger.py
Outdated
@@ -13,6 +13,8 @@ | |||
from dbt_common.events.format import timestamp_to_datetime_string | |||
from dbt_common.utils.encoding import ForgivingJSONEncoder | |||
|
|||
from dbt_common.events.types_pb2 import PrintEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we could avoid importing from types_pb2 if we can, because those classes don't always behave like "real" Python classes and it would be nice to isolate the importing of those classes to just the matching xxx_types.py files. Could we look at msg.info.name instead? It should be the string "PrintEvent".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! This also makes it easier if we need to do some expansion.
related to dbt-labs/dbt-core#8756
Related PR dbt-labs/dbt-core#10131
Description
We want to have some event that
--quiet
is specified,This PR does so by creating a specific event in dbt-common and implemented logic to have this event always passed to logger as 'error' level.
Checklist
changie new
to create a changelog entry