-
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-679] [Bug] when shelling out to dbt, disabling colored output still prints out the reset color code #5288
Comments
I tried this in a standard terminal and it works fine. Is this behavior dependant on using that DbtShellTask that you linked to? Because if it works fine in a normal terminal and doesn't underneath that application, I'm wondering if there is an issue with DbtShellTask. |
it's probably more of a problem with anything that wants programmatic access to the logs for whatever reason. here's a super small snippet (modified from DbtShellTask's parent functionality) showing what's going on: import os
from subprocess import Popen, PIPE
with Popen(["dbt", "--no-use-colors", "compile"], stdout=PIPE, shell=False) as sub_process:
lines = []
for raw_line in iter(sub_process.stdout.readline, b""):
line = raw_line.decode("utf-8").rstrip()
lines.append(line)
sub_process.wait()
print(lines) results in: $ python test.py
['\x1b[0m18:17:51 Running with dbt=1.1.0', '\x1b[0m18:17:52 Found 358 models, 497 tests, 4 snapshots, 0 analyses, 638 macros, 12 operations, 2 seed files, 128 sources, 55 exposures, 0 metrics', '\x1b[0m18:17:52', "\x1b[0m18:17:56 Concurrency: 4 threads (target='testing')", '\x1b[0m18:17:56', '\x1b[0m18:18:18 Done.'] since it's not a "real" shell, it won't resolve that reset color code automatically and thus it's still hanging out there when prefect/ |
It looks like this might be due to a programming error in core/dbt/events/functions.py. The line Would you be interested in trying this and doing a pull request? |
sure, i'll give it a whirl! i found that line too but hadn't dug too deep to know if that was the right spot to change. |
Is there an existing issue for this?
Current Behavior
when shelling out to dbt (a la Prefect), disabling colored output still prints the reset color code.
Expected Behavior
no color codes should be printed when colored output is disabled
Steps To Reproduce
dbt >= 1.0.0
Relevant log output
What database are you using dbt with?
redshift
Additional Context
this line here looks to be the culprit
The text was updated successfully, but these errors were encountered: