ibis
ibis copied to clipboard
When verbose = True and interactive = True are used in Jupyter, SQL log messages are printed twice
When using Jupyter in a browser, it will render outputs in both text and HTML every time regardless of which is being displayed. Both of these calls are generating the SQL log output when verbose = True. These log calls should be disabled in all of the _repr_*_
methods like _repr_html_
that call execute()
.
I don't know if there is a better way to handle it, but the easy fix is to change _repr_html_
methods to something like the following:
def _repr_html_(self) -> str | None:
if not ibis.options.interactive:
return None
verbose = ibis.options.verbose
ibis.options.verbose = False
out = self.execute().to_frame()._repr_html_()
ibis.options.verbose = verbose
return out
I found two occurrences of these methods in expr/types/relations.py
and expr/types/generic.py
.
This may actually be a sign of a bigger issue. If both the text representation methods and HTML representation methods call execute()
that means the query is getting run multiple times. The query output probably should be cached in the first method and used by any other IPython methods that do rendering.
Thanks for opening this issue @kesmit13, I can confirm the behavior you're seeing here. We should be able to resolve this by defining _repr_mimebundle_
and handling all supported formats within a single method. I'll push a fix up for this tomorrow.
Apologies for the delay here @kesmit13, this should be fixed in #4587.
Note that this only fixes the accidental double execution, and not the logging behavior. The intent of verbose mode is to always log when a query is executed. The log location can be configurable, so users can log queries to e.g. a file. We shouldn't disable query logging just because a query is executed during a repr.