[CT-172] `--quiet` flag for run-operations
See original GitHub issueDescribe the feature
Currently, when you run run-operation
you get the output of your macro after a few lines of text, for example:
Running with dbt=0.19.1
[WARNING]: Configuration paths exist in your dbt_project.yml file which do not apply to any resources.
There are 2 unused configuration paths:
- seeds
- snapshots
{macro output here}
I’m proposing a --quiet
flag for run-operation
that would remove the Running 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!
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (17 by maintainers)
Top Results From Across the Web
Quiet - IBM
The quiet option limits the number of messages that are displayed on your screen during processing.. For example, when you run the incremental,...
Read more >How to set --quiet flag by default in git? [duplicate]
You can't set the quiet flag for all your commands in the gitconfig. As @torek mentioned, there is no way to set built-in...
Read more >american-flag - Loud And Quiet
american-flag. ↑. Loud And Quiet. Moderately successful since 2005. •. Subscribe · Shorts · Interviews · Podcasts · Reviews.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
--quiet
whose sole purpose is to silence logs to stdout. This will be a global flag that is added toflags.py
andmain.py
(following the example of --debug or --log-cache-events). In this new context where it’s only purpose is to not log anything to stdout,--quiet
makes more sense as the flag name.No new event base classes need to be created with this route either. We can leverage the already existing
NoStdOut
.You will need to modify the below code to swallow the log for
flags.QUIET
similar to what we do forflags.DEBUG
on line 352. https://github.com/dbt-labs/dbt-core/blob/2d0b975b6c2023cde219f0a045709a1fa5c6c840/core/dbt/events/functions.py#L349-L367Second, let’s add a
{{ print() }}
function to macros! It will be very similar to{{ log() }}
. The difference being thatprint
is not a log statement, it will just print to stdout.To do this, you can copy the approach we have for log. It should always just print to stdout.
https://github.com/dbt-labs/dbt-core/blob/2d0b975b6c2023cde219f0a045709a1fa5c6c840/core/dbt/context/base.py#L475-L494
These two changes (and a change to
codegen
to use this newprint
statement) would result indbt run-operation generate_source --args '{"schema_name": "jaffle_shop", "database_name": "raw"}'
to print to stdout anyprint
statements ingenerate_source
but no logs. Logs would however still be written to the file.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
Loud
path unnecessarily (yet).