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

Support installation of custom widgets. #498

Closed
blois opened this issue Mar 28, 2019 · 50 comments
Closed

Support installation of custom widgets. #498

blois opened this issue Mar 28, 2019 · 50 comments

Comments

@blois
Copy link
Contributor

blois commented Mar 28, 2019

Currently Colab only supports the widgets included in the ipywidgets package and does not allow installing additional widgets.

Additional background is available at https://github.com/nteract/nes/tree/master/portable-widgets.

@korakot
Copy link

korakot commented Apr 27, 2019

Qgrid would make it easier to work with pandas dataframe.

Hope it will be supported in the future.

@cornhundred
Copy link

cornhundred commented May 7, 2019

We're building a custom widget called Clustergrammer2 that is a webgl DataFrame viewer and is currently supported on Kaggle https://www.kaggle.com/cornhundred/heatmap-view-of-modern-era-player-stats

Also see nbviewer https://nbviewer.jupyter.org/github/ismms-himc/clustergrammer2-notebooks/blob/master/notebooks/3.0_10X_Genomics_2700_Dataset_NBViewer.ipynb

@blois
Copy link
Contributor Author

blois commented May 7, 2019

Glancing at the widget code in https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L222, it doesn't seem like it's making much use of the Widgets API, specifically comms messages.

A quick example of your (very slick) notebook running in Colab, with the visualizations:
https://colab.sandbox.google.com/gist/blois/dd01cd63d199acca951aadefb22067a8/heatmap-view-of-modern-era-player-stats.ipynb

@cornhundred
Copy link

cornhundred commented May 7, 2019

Thanks @blois for your help. In order to run the notebook you sent I had to add the Seasons_Stats.csv (from here https://www.kaggle.com/drgilermo/nba-players-stats) to the filesystem.

However, I did not see the interactive visualization. Update: the heatmap did show up after a minute. I'll think about how to clean up the implementation. Thanks again!!

Looking forward to custom widget support, but this definitely helps out in the interim.

BTW @blois, how can I upload a dataset permanently into a shareable colab notebook (e.g. the sandbox link you sent)?

Here is a link to a notebook that does not require an external dataset https://colab.research.google.com/gist/cornhundred/b7154ee964c71cec6a2378f9cbba8eeb/clustergrammer2_example.ipynb?authuser=1

cc @manugarciaquismondo.

@blois
Copy link
Contributor Author

blois commented May 17, 2019

@korakot we recently added an interactive dataframe viewer that we've been using internally for ages.

You can enable it by default with:

%load_ext google.colab.data_table
from vega_datasets import data
data.cars()

Or use it on a per-dataframe basis:

from google.colab.data_table import DataTable
from vega_datasets import data
DataTable(data.cars())

@korakot
Copy link

korakot commented May 18, 2019

@blois Thanks a lot. It will surely help.

BTW, is there a widget to edit the dataframe as well?

And what other %load_ext are available? Is there a list somewhere?

@Kreijstal
Copy link

Kreijstal commented Jun 20, 2020

can you install custom widgets now? I'd like to have a variable previewer just like allefeld/ipyinspector#1

@Location-Artistry
Copy link

This problem still persists with Google Colab on August 13th, 2020.
ArcGIS Python API maps will not display.
All the other portions of the API seem to work great in Colab, and I am able to conduct ArcGIS Online Admin from Colab.
Currently switching over to the AGOL Jupyter Notebook interface to view the map widget display.
Perhaps there could be a clever workaround by exporting to html or viewing as JavaScript.

@giswqs
Copy link

giswqs commented Sep 19, 2020

@blois Please add support for ipyleaflet, which would make visualizing and interacting Google Earth Engine tile layers much easier with the earthengine-api. @tylere @SylvainCorlay @martinRenou @davidbrochart

@jasonho-lynx
Copy link

Hi, let me know if this isn't the right place - it would be great to have support for pymotif, which is a Jupyter widget for Motif, a no-code graph visualization platform. Thank you! @timlrx

@ucalyptus
Copy link

@blois any updates on this?

@JesseFarebro
Copy link

JesseFarebro commented Nov 22, 2021

@kylebarron I tried debugging this and the messages are passed without issue. It seems the proper commands are sent to plotly but nothing is being displayed (i.e., the entire DOM element for plotly is empty). It would be really nice to have this working in Colab.

@kylebarron
Copy link

The plot appears for me when you call g.show() in a cell. Though the message passing doesn't appear to work immediately for me.

Just noting that I was wrong here. The Plotly FigureWidget subclasses from both BaseFigure and widgets.DOMWidget. The .show() comes from BaseFigure, so when you call .show it's rendering a static HTML output without touching the widget machinery at all. When you render the widget directly in a cell, i.e.

from google.colab import output
output.enable_custom_widget_manager()

import plotly.graph_objects as go
f = go.FigureWidget(layout={'height': 400, 'width': 400})
f

if you look in the network tab the right plotly widget bundle gets downloaded (plotlywidget for plotly v4 and jupyterlab-plotly for plotly v5). I'm guessing there's some sort of bad interaction with Colab's widget manager but it's hard to tell.

@blois
Copy link
Contributor Author

blois commented Nov 22, 2021

@kylebarron @JesseFarebro Details on the Plotly issue are in googlecolab/colab-cdn-widget-manager#19.

@cardinalgeo
Copy link

Thanks for taking a look at this @kylebarron @JesseFarebro, and thanks for the quick fix @blois—I'm looking forward to seeing it go live!

@blois
Copy link
Contributor Author

blois commented Nov 24, 2021

@cardinalgeo your example should now be working, see googlecolab/colab-cdn-widget-manager#19 (comment).

@cardinalgeo
Copy link

cardinalgeo commented Nov 25, 2021

Thanks @blois! However, the example is unfortunately still not working. Running the block in the jupyter lab screenshot below should produce both the widgets and the plot, as is pictured. But running the same cell in colab only produces the widgets. I can run g.show() in a separate cell to display the plot, but, while the message passing seems to work, a change in the dropdown widgets only results in a change in the plot after re-running g.show(), which is not ideal. Do you have any idea why the widgets and figure aren't both being displayed in the output such that a change in the widgets automatically produces a change in the figure?
Screen Shot 2021-11-24 at 9 07 12 PM

@kylebarron
Copy link

From my comment here #498 (comment)

The Plotly FigureWidget subclasses from both BaseFigure and widgets.DOMWidget. The .show() comes from BaseFigure, so when you call .show it's rendering a static HTML output without touching the widget machinery at all.

In order to render the widget and not the static HTML output mode, you need to render without .show. The below Colab notebook is a direct copy of this page in the Plotly docs, adding only the command to enable custom widgets.

Open In Colab

Here, the widget doesn't render, and I see this console error:
image

@lukewys
Copy link

lukewys commented Nov 30, 2021

Here's an example for qgrid: https://colab.research.google.com/gist/blois/3b36d0aa4c32d2ecc71e9208c32cf333/qgrid.ipynb

For those who want to use qgrid in their Colab notebook but don't want to confuse people on colab force restart, I found a workaround for using qgrid without restarting the session. The question is about qgrid 1.1.1 not supporting pandas>1.0.0. You can fork qgrid to your own repo, roll back the version to 1.1.1, and change the code according to quantopian/qgrid#287. Then, you could pip install via git from your repo.

For example, you can do pip install git+https://github.com/lukewys/qgrid.git (a fork of qgrid where I fixed this issue).

@tylere
Copy link

tylere commented Dec 20, 2021

Please add support for the ipytree widget too: #2522

@cardinalgeo
Copy link

Here, the widget doesn't render, and I see this console error:

@kylebarron thanks for the Plotly widget example! I can't find a way to view the console error (is it from terminal, which is only available with colab pro)? Do you have any sense of whether this issue can be resolved on the Colab side or if it will require work on the Plotly side?

@blois
Copy link
Contributor Author

blois commented Dec 20, 2021

@cardinalgeo Support for the plotly widgets was tracked in googlecolab/colab-cdn-widget-manager#19. There's a link to your example working in there.

@blois
Copy link
Contributor Author

blois commented Dec 20, 2021

At this point installation of custom widgets is supported. This requires opting in by using the code:

from google.colab import output
output.enable_custom_widget_manager()

Specific widgets may need additional investigation or tweaks. It's easiest to open individual issues for these investigations. Most of the bugs have been tracked in https://github.com/googlecolab/colab-cdn-widget-manager/issues?q=is%3Aissue.

@blois blois closed this as completed Dec 20, 2021
@cardinalgeo
Copy link

Hi @blois, thanks for the follow up! However, the example still seems to not work. I'll continue this thread in googlecolab/colab-cdn-widget-manager#19

@martinRenou
Copy link

Thanks a lot for your work on this @blois !

@cornhundred
Copy link

Thanks @blois!!! This is amazing!

@nulflux
Copy link

nulflux commented Aug 19, 2022

Today ipywidgets Text will no longer work. There is a message about adding two lines to allow external widgets loading but that does not fix the problem.

@colaboratory-team
Copy link
Contributor

@nulflux downgrading the ipywidgets version should work for you until we can get a fix out:

!pip install ipywidgets==7.7.1 and then restart your runtime

@nulflux
Copy link

nulflux commented Aug 19, 2022 via email

@blois
Copy link
Contributor Author

blois commented Aug 22, 2022

Added some details on the issue in #3020 (comment).

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

No branches or pull requests