Closed SebastianRiechert closed 2 months ago
Thanks for flagging this, @SebastianRiechert! I've asked @2timesjay, who's most familiar with this part of the code, to look into it.
Hi @SebastianRiechert , the discussion on #332 lead to the solution for the jupyterlab half of this issue. copying that here:
This is unfortunately a problem with all JupyterLab plotly plotting.
I was able to resolve it by following https://plotly.com/python/getting-started/#jupyterlab-support-python-35 and installing the jupyter labextension suggested.
Please let us know if this works for you.
Alternately, Jupyter Notebooks should not encounter this problem.
The colab issue is unexpected: https://stackoverflow.com/questions/47230817/plotly-notebook-mode-with-google-colaboratory describes the issue as resulting from using older plotly versions, but we're on plotly >4.4 and still running into it. While I investigate further, the workaround from the top answer there DOES work in colab.
Closing as duplicate, let's direct all future discussion of this issue to #332.
Still investigating colab half of this issue (realized this one was the right one to host discussion on).
Support for Colab is considered wishlist for now, porting this to https://github.com/facebook/Ax/issues/566.
Workaround for making Ax plots work in colab is a function like this (source: https://stackoverflow.com/questions/47230817/plotly-notebook-mode-with-google-colaboratory, this seems to apply to Plotly verstions 3.x overall):
def configure_plotly_browser_state():
import IPython
display(IPython.core.display.HTML('''
<script src="/static/components/requirejs/require.js"></script>
<script>
requirejs.config({
paths: {
base: '/static/base',
plotly: 'https://cdn.plot.ly/plotly-latest.min.js?noext',
},
});
</script>
'''))
So you would call that function before rendering a plot, e.g.:
configure_plotly_browser_state()
render(ax_client.get_contour_plot())
We'll incorporate this into a convenient utility soon as well (maybe just making it part of render
), at which point we'll close the issue.
Here's a simple workaround. Add
import plotly.io as pio
pio.renderers.default = "colab"
to the NB running on colab. The figure renders and is interactive :) (for smaller notebook file size at the expense of non-interactive plots, you can use "png" as the renderer)
Note: You also need to do !pip install kaleido
.
This is now covered in documentation: https://ax.dev/tutorials/visualizations.html#Fix-for-plots-that-are-not-rendering and a warning will be raised in the code directing users to the documentation. @septfreur, @sgbaird, @SebastianRiechert FYI
I have tried running this tutorial both in google colab and in jupyterlab on a remote server setup.
https://ax.dev/tutorials/tune_cnn.html
Both times the render()-call returns an empty output.
This is the code, no changes from tutorial except installation of ax:
switching to classic jupyter notebook (in remote setup) as suggested in https://github.com/facebook/Ax/issues/94 doesn't change anything.
pip freezes for both environments:
colab_pip_freeze.txt
jupyterlab_pip_freeze.txt