-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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-172] --quiet
flag for run-operations
#3451
Comments
@jaypeedevlin This makes sense to me. I know this has been a challenge when using the codegen package in particular, and I feel more comfortable with this answer than with Jinja-based file generation (#3428). It sounds like the ask is: Everything info-level that would normally log to stdout, should be ignored in stdout and log to I don't know exactly how this ought to work, beyond that it will require some changes to
That's just one idea. I'd curious to hear from other members of the Core team, who likely have better ones. |
This is significantly easier than previously I thought, since I realized we already do it for If the This will still require setting the Jinja context Going to call this one a good first issue! |
If it's done by default for |
@jaypeedevlin I definitely see merit in that argument. Some run-operations are more like quasi-tasks (thinking about All in all, the code in |
Is there a reason why dbt log messages go to stdout by default instead of always to stderr? The convention I'd expect from a shell utility command is for "log" messages to always go to stderr and for there to be a separate call used to explicitly write to stdout (maybe |
@vergenzt That's effectively the function of One complication to my proposal above: |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days. |
Commenting to leave this open, I'd like to take a pass at this in the new year. |
@jaypeedevlin Very cool :) Since we reworked logging in v1, most of my comments above are no longer relevant! In fact, I'm hopeful it will be much easier to plumb through the logic that sets log levels |
Hey there @jtcohen6 — I've started working on this one with @ehmartens, and we could use your help (or someone elses if there's someone better placed to assist!). Here's what we discovered today: There are three 'portions' of potential output from a run-operation that doesn't error:
Our aim is to display only 3 and any additional errors. Our first approach was to borrow this classmethod from the list command which overrides the logging level. Unfortunately that is designed to suppress info, so we got just the warning. We want a way to suppress the We thought if there was some way to set the initial log level to ERROR and then raise it to INFO just before the macro runs it would give us what we wanted (and then we could work on making it conditional on an arg/flag), but we're not sure how to go about that. Any guidance you (or anyone else) could provide to steer us in the right direction would be welcome! |
@jaypeedevlin @ehmartens Hooray! I do think this will be significantly easier in the new logging system, which has a README :) It should give us much more flexibility than with the old system, such that we should also be able to find a better way than how the Here's what I'm thinking:
I took a quick crack at that, and ended up with:
Note this will include all info-level log events fired via the dbt-Jinja |
It's exciting just how much easier this is with the new logging system! This approach seems spot on but happy to help out if there are any more questions. Small note: I don't love the class name of |
Heh, super legit note - I was having a bit too much fun on a Friday. ( |
After giving this a bit more thought I'm thinking we may want to go down the path of a new log level. I'd like to think through the implications of it a bit more before saying we should definitely go that route. But wanted to put a note here so @jaypeedevlin and @ehmartens don't start down the |
@jaypeedevlin and @ehmartens after giving this a lot more thought a new log level is not the right way to go. Please correct me if there's something I'm missing but the heart of this issue is that you want to be able to see just the output generated via With that in mind, the basic approach that @jtcohen6 laid out with a flag and new base event class is spot on with one minor tweak. Since a user doesn't know that the output of So pulling from the basic outline above:
The new flag will need to be defined as Line 1125 in 2d0b975
should become
Then there needs to be a new function following the pattern of
Please let me know if you have any questions about this approach! If you don't think the name of the flag is intuitive I'm happy to start a conversation about it as well. |
@jaypeedevlin and @ehmartens the team and I have come up with an even more robust solution that will fix a few different situations. While my previous solution would work, this is better long term. #4687 recently requested the ability to silence logs to stdout as well. The general solution is two fold. First, add a flag No new event base classes need to be created with this route either. We can leverage the already existing You will need to modify the below code to swallow the log for dbt-core/core/dbt/events/functions.py Lines 349 to 367 in 2d0b975
Second, let's add a To do this, you can copy the approach we have for log. It should always just print to stdout. dbt-core/core/dbt/context/base.py Lines 475 to 494 in 2d0b975
These two changes (and a change to |
Flagging @joellabes so he's aware we're going to add a |
--quiet
flag for run-operations--quiet
flag for run-operations
Thank you! |
Describe the feature
Currently, when you run
run-operation
you get the output of your macro after a few lines of text, for example:I'm proposing a
--quiet
flag forrun-operation
that would remove theRunning with dbt
and any other warnings, leaving just the output of the macro.Describe alternatives you've considered
I've previously wrapped calls to
run-operation
in bash script which trims the first line from the output, however when warnings are triggered (like the example above) it's hard to tell in advance how many lines to trim.Who will this benefit?
Anyone who uses the codegen macro (and similar macros) outside of dbt cloud
Are you interested in contributing this feature?
Yes — I've poked around the logger code but couldn't see a straightforward way of doing this, but I'm open to trying with some input!
The text was updated successfully, but these errors were encountered: