Skip to content
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

Ct 738/dbt debug log fix #6541

Merged
merged 18 commits into from
Jan 21, 2023
Merged

Ct 738/dbt debug log fix #6541

merged 18 commits into from
Jan 21, 2023

Conversation

VersusFacit
Copy link
Contributor

@VersusFacit VersusFacit commented Jan 7, 2023

resolves #5353

The world is a book repo and those who do not travel read only a page file. ~Augustine...or something

And what a fun, instructive excursion this was. I got to edit some CLI jobs and walk around some execution parts of the repo -- how exciting 😊

What does this PR do?

dbt debug structured logging

  1. dbt --log-format json debug and DBT_LOG_FORMAT=json dbt debug both now render as structured logs
    • they were only doing so piecemeal before this PR
  2. there's not a single print left in the file -- sweet!
  3. tested for a working case (my own trusty snowflake connection) -- screenshots omitted
  4. tested for a failing class (profile missing) -- screen shots below 👇

dbt {ls,list} structured logging

  1. dbt --log json {ls,list} and DBT_LOG_FORMAT=json dbt {ls,list} prints structured logs now, under info level
  2. dbt {ls,list} continues to print just the names (🔪 -ed out some overrides and a TODO or two)

Before and After Screenshots

My debugging strategy:

clear; dbt debug; echo "======"; dbt --log-format json debug

Check evolving structured logs against plain ol' dbt debug.

Before, several printed lines:
Screen Shot 2023-01-07 at 12 18 22 AM

After, they're all structured logs now:
Screen Shot 2023-01-07 at 12 29 41 AM

Minor caveat: These were taken in two different iterations so the connections listed are slightly different, but I just have lots of profiles :p

Outstanding Questions

  1. I generated my protobuf types with protoc -I. --python_betterproto_out=. types.proto. Hope that's right 🙇‍♀️
  2. Jeremy over on the issue thread might suggest a different spec than what I served here.

Checklist

@VersusFacit VersusFacit added the enhancement New feature or request label Jan 7, 2023
@VersusFacit VersusFacit requested a review from a team January 7, 2023 08:31
@VersusFacit VersusFacit self-assigned this Jan 7, 2023
@VersusFacit VersusFacit requested review from a team as code owners January 7, 2023 08:31
@cla-bot cla-bot bot added the cla:yes label Jan 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2023

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.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2023

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.

core/dbt/tests/util.py Outdated Show resolved Hide resolved
@VersusFacit VersusFacit requested a review from jtcohen6 January 8, 2023 02:27
core/dbt/task/list.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VersusFacit The branch for the PR has conflicts to be resolved. Could you resolve those?

core/dbt/tests/util.py Outdated Show resolved Hide resolved
tests/functional/profiles/test_profile_dir.py Outdated Show resolved Hide resolved
Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs to have main merged because there have been a lot of changes in the events code and the messages as implemented in types.proto here will no longer work.

Rather than a bunch of new logging events I would prefer to have them combined as much as makes sense. We are going through an exercise of reducing the number of events and this is going in the opposite direction.

core/dbt/compilation.py Show resolved Hide resolved
core/dbt/events/proto_types.py Outdated Show resolved Hide resolved
core/dbt/events/types.proto Outdated Show resolved Hide resolved
core/dbt/task/list.py Outdated Show resolved Hide resolved
core/dbt/tests/util.py Outdated Show resolved Hide resolved
@VersusFacit VersusFacit force-pushed the CT-738/dbt_debug_log_fix branch from 9a8c470 to f0c5f5b Compare January 20, 2023 03:28
Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

class TestProfiles:
def dbt_debug(self, project_dir_cli_arg=None, profiles_dir_cli_arg=None):
def dbt_debug(self, project, project_dir_cli_arg=None, profiles_dir_cli_arg=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited about all the simplification you were able to do for the tests/functional/profiles/test_profile_dir.py test!

Is adding project essential? If not, what do you think about leaving it as the following?

Suggested change
def dbt_debug(self, project, project_dir_cli_arg=None, profiles_dir_cli_arg=None):
def dbt_debug(self, project_dir_cli_arg=None, profiles_dir_cli_arg=None):

Copy link
Contributor Author

@VersusFacit VersusFacit Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbeatty10 It is because under the hood, the dbt invocation needs the profile for the run command; otherwise run_dbt or run_dbt_and_capture won't work -- without this I run into "profile not found errors". Kept barking at me during development.

You have a better solution by chance?

Copy link
Contributor Author

@VersusFacit VersusFacit Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, I was wrong. This was needed at some point, but now I can go in and remove it. Thanks for the callout 🙇‍♀️ 😅 I need to dive in the next time I find the error I describe, so I can identify if it's a context-specific bug or something more general. I've run into it too many times to be misremembering that, but also, my understanding of it has now been shifted as a result of this convo.

tl;dr merged your change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries!

Will be a very happy day once this is merged and my custom run_dbt_and_capture_stdout is no longer a thing!

Will re-review shortly.

@dbeatty10 dbeatty10 self-requested a review January 20, 2023 20:43
Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only reviewed the changes to tests/functional/profiles/test_profile_dir.py, and they look great!

Relying on other reviewers to cover everything else.

@dbeatty10 dbeatty10 dismissed their stale review January 20, 2023 20:46

Behavior was confirmed and suggestion was applied

@VersusFacit VersusFacit merged commit 93619a9 into main Jan 21, 2023
@VersusFacit VersusFacit deleted the CT-738/dbt_debug_log_fix branch January 21, 2023 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-738] [Enhancement] dbt debug command not outputting logs correctly
4 participants