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

Databricks notebook renderer #1684

Closed
nicolaskruchten opened this issue Jul 24, 2019 · 2 comments
Closed

Databricks notebook renderer #1684

nicolaskruchten opened this issue Jul 24, 2019 · 2 comments

Comments

@nicolaskruchten
Copy link
Contributor

Right now it seems like the only way to render in Databricks notebook is via displayHTML(fig.to_html()).

From Slack:

Is displayHTML a built-in databricks thing? If so, then this could be done as ExternalRenderer renderer, where the side-effect is calling displayHTML. And we could use the presence of that function in the global namespace to automatically enable the renderer.

Basically identical to BrowserRenderer (

class BrowserRenderer(ExternalRenderer):
"""
Renderer to display interactive figures in an external web browser.
This renderer will open a new browser window or tab when the
plotly.io.show function is called on a figure.
This renderer has no ipython/jupyter dependencies and is a good choice
for use in environments that do not support the inline display of
interactive figures.
mime type: 'text/html'
"""
def __init__(
self,
config=None,
auto_play=False,
using=None,
new=0,
autoraise=True,
post_script=None,
animation_opts=None,
):
self.config = config
self.auto_play = auto_play
self.using = using
self.new = new
self.autoraise = autoraise
self.post_script = post_script
self.animation_opts = animation_opts
def render(self, fig_dict):
from plotly.io import to_html
html = to_html(
fig_dict,
config=self.config,
auto_play=self.auto_play,
include_plotlyjs=True,
include_mathjax="cdn",
post_script=self.post_script,
full_html=True,
animation_opts=self.animation_opts,
default_width="100%",
default_height="100%",
validate=False,
)
open_html_in_browser(html, self.using, self.new, self.autoraise)
)
but calling displayHTML instead of open_html_in_browser. We should probably extract a shared ExternalHtmlRenderer parent class too. Then add an auto-detect section like the colab one in
if not default_renderer:
try:
import google.colab
default_renderer = "colab"
except ImportError:
pass
. But it would check for a NameError on the displayHTML function.

@LePuppy
Copy link

LePuppy commented Sep 13, 2019

Hi, I'm actually displaying graph_objects figures inside Databricks ! I build the figure then use fig.show() and this work perfectly for me.

@nicolaskruchten
Copy link
Contributor Author

Ah yes, we did this in #1703

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants