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-217] add --no-print flag #4710

Closed
1 task done
emmyoop opened this issue Feb 10, 2022 · 1 comment · Fixed by #4854
Closed
1 task done

[CT-217] add --no-print flag #4710

emmyoop opened this issue Feb 10, 2022 · 1 comment · Fixed by #4854
Labels
enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors!

Comments

@emmyoop
Copy link
Member

emmyoop commented Feb 10, 2022

Is there an existing feature request for this?

  • I have searched the existing issues

Describe the Feature

Add a flag to suppress {{ print(msg) }} messages coming out of macros. Docs for print to be added here.

print functionality in macros was added in as part of #3451 but there is currently no way to keep the messages from being printed to stdout. This can result in these messages interspersed with logs going to stdout.

The change will involve adding a flag to flags.py and main.py called --no-print. Copying the way quiet was implemented will get you where you need to go.

Logic also needs to be added to stop printing to stdout. This can be accomplished by wrapping the print command with an if statement for when the --no-print flag is false.

def print(msg: str) -> str:
"""Prints a line to stdout.
:param msg: The message to print
> macros/my_log_macro.sql
{% macro some_macro(arg1, arg2) %}
{{ print("Running some_macro: " ~ arg1 ~ ", " ~ arg2) }}
{% endmacro %}"
"""
print(msg)
return ''

Once this is all done, docs.dbt.com will also need top be updated. Specifically, this page. Open an issue over in that repo for that piece of this.

Describe alternatives you've considered

Not doing this simply means that {{ print(msg) }} will always print to stdout.

Who will this benefit?

Right now, anything sent to stdout using {{ print(msg) }} will get printed to stdout all the time with no way to suppress it. This will allow anyone using macros utilizing print to suppress those messages.

Are you interested in contributing this feature?

No response

Anything else?

No response

@emmyoop emmyoop added enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors! labels Feb 10, 2022
@github-actions github-actions bot changed the title add --no-print flag [CT-217] add --no-print flag Feb 10, 2022
@ehmartens
Copy link
Contributor

Hi @emmyoop 👋 Thanks for all of your help on #3451 My coworker @poloaraujo and I are planning to take a crack at this! We'll get going next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants