<@ULVA73B9P> Is there a supported way to suppress the per-node logs/events produced by PrefectDbtR...
g
@Marvin Is there a supported way to suppress the per-node logs/events produced by PrefectDbtRunner.invoke() when running dbt ls? Redirecting stdout/stderr does not suppress them because they appear to be emitted through Prefect’s logging callbacks. We want to keep using PrefectDbtRunner, rather than calling dbt’s native dbtRunner directly. Is there a setting or callback configuration to disable these logs while still obtaining result.result?
m
thought for 85.9 seconds
Yes — if you’re on a recent Prefect version,
PrefectDbtRunner
has a way to suppress those callback-driven per-node logs/events:
Copy code
python
from prefect_dbt import PrefectDbtRunner

runner = PrefectDbtRunner(_disable_callbacks=True)
result = runner.invoke(["ls"])

# You still get the dbt result object
print(result.result)
A few important notes: -
_disable_callbacks=True
prevents
PrefectDbtRunner
from registering the Prefect/dbt event callbacks that emit the per-node logs. - You still get the invocation result, including
result.result
. - This is an internal/private constructor argument, not a documented public setting, so treat it as version-sensitive. I verified this from the source: - `_disable_callbacks` in `PrefectDbtRunner` constructor - callback creation logic in `invoke()` So the short answer is: - Supported public setting/config? No, I couldn’t find a documented public callback/logging config for this. - Practical way while still using
PrefectDbtRunner
?
Yes:
PrefectDbtRunner(_disable_callbacks=True)
. Example:
Copy code
python
from prefect_dbt import PrefectDbtRunner

runner = PrefectDbtRunner(
    _disable_callbacks=True,
)

result = runner.invoke(["ls", "--select", "my_selector"])

# Consume dbt output as usual
print(result.result)
If you want, I can also help you: - check whether your installed
prefect-dbt
version includes this flag, or - suggest a safe fallback pattern if you’re on an older release where
_disable_callbacks
is not available.