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

Table Widget doesn't render in Google Colab #3

Open
anastasia-si opened this issue Aug 8, 2022 · 10 comments
Open

Table Widget doesn't render in Google Colab #3

anastasia-si opened this issue Aug 8, 2022 · 10 comments
Assignees
Labels
bug Something isn't working devrel-watch Tickets being watched by DevRel

Comments

@anastasia-si
Copy link

Description

Deephaven’s Table Widget isn’t rendering in Google Colab.

Steps to reproduce

Use test Google Colab notebook:
https://colab.research.google.com/drive/1Nz-ahfZQW7Hi3f7_X1LI12RTr50130Qv#scrollTo=Kz79bURo18N

Details
Browser: Chrome

Slack thread: https://illumon.slack.com/archives/C03F03BFMAB/p1659710939673389

From Colin Alworth:

it appears that the serve_kernel_port_as_iframe(dh_port) or serve_kernel_port_as_window(dh_port) call is not forwarding correctly - we either see 500s or 403s, while loading the same content locally seems to work (and it ought to be http/1.1 for at least loading the index.html, or the redirect anyway). my hunch is that someone is going to need to start with a very simple http server in python and make sure that loads, and progressively make it more and more interesting to see at what point the google collab proxy craps out.

notes that the dh_port value is embedded in the domain name - it is https://${some junk}-${more junk}-${port}-colab.googleusercontent.com , such as https://01a0wpl5ww4-496ff2e9c6d22116-17237-colab.googleusercontent.com/. Also tried appending /ide/ and /ide/index.html, but to no avail

@anastasia-si anastasia-si added the bug Something isn't working label Aug 8, 2022
@mofojed
Copy link
Member

mofojed commented Sep 14, 2022

A different Google Collab notebook opening a simple web server: https://colab.research.google.com/notebooks/snippets/advanced_outputs.ipynb#scrollTo=_7dYIo63EdgL

As Colin pointed out, running something like:

from google.colab import output
output.serve_kernel_port_as_iframe(port)

... which should show the web UI, instead results in many errors. The API for server_kernel_port_as_iframe is defined here in GitHub: https://github.com/googlecolab/colabtools/blob/master/google/colab/output/_util.py#L49

I also tried adding the path to '/ide/index.html', e.g.:

from google.colab import output
output.serve_kernel_port_as_iframe(port, '/ide/index.html')

And that results in a 404:
image

The resulting iframe HTML was:

<iframe src="https://5bkdheicoqk-496ff2e9c6d22116-8899-colab.googleusercontent.com/ide/index.html" style="border: 0px none;" width="100%" height="400"></iframe>

@mofojed
Copy link
Member

mofojed commented Sep 14, 2022

Actually, getting a bit further when using Chrome instead of Firefox. Still complaining about not using http2, so something in the proxy is screwing things up.

image

@mofojed
Copy link
Member

mofojed commented Oct 6, 2022

Looks similar to googlecolab/colabtools#3079

@mofojed
Copy link
Member

mofojed commented Oct 6, 2022

There are two issues at play here:

  1. Instead of using localhost, need to generate the URL correctly using google.colab.kernel.proxyPort, but I don't really understand how to use that. It's only used in iframe generation here (and executed from a JS context??): https://github.com/googlecolab/colabtools/blob/master/google/colab/output/_util.py#L71. I can't really find any documentation on it. We pass the server URL to the frontend though, and it's using localhost which is a problem: https://github.com/deephaven/deephaven-ipywidgets/blob/main/deephaven_ipywidgets/deephaven.py#L63
  2. We need to configure to not require/use http2: https://github.com/deephaven/deephaven-core/blob/main/server/jetty/src/main/java/io/deephaven/server/jetty/GrpcFilter.java#L28
    It looks like the Google Colab proxy only supports http1.1, possibly because it's using a service worker

image

There's a brief mention in the FAQ of using service workers: https://research.google.com/colaboratory/faq.html#third-party-cookies

@mofojed
Copy link
Member

mofojed commented Oct 7, 2022

Added a ticket for being unable to set config values when using Deephaven as a library: deephaven/deephaven-core#2964
This affects item 2 above

@mofojed mofojed self-assigned this Oct 7, 2022
@mofojed
Copy link
Member

mofojed commented Oct 7, 2022

Can use JVM args to get around dh_args doing nothing:

s = Server(port=dh_port, jvm_args=["-Dhttp.requireHttp2=false"])

However, it looks like the proxy shuts down after a couple connections, so I'm not sure how to address this issue. Seems like the proxyPort is not expecting the connection to stay open? Not sure yet.

@mofojed
Copy link
Member

mofojed commented Oct 11, 2022

We may have to do some environment inspection to figure out how to display ourselves, which is kind of gross. Take a look at plotly: https://github.com/plotly/plotly.py/blob/49dfcb1868e87627f032731ef2ac48e37891baf4/packages/python/plotly/plotly/io/_renderers.py#L472

jnumainville added a commit that referenced this issue Dec 16, 2022
Part of fix for #3

Added logic to check if the script is being ran in google colab, then replace the server url with proxied url for the specified port if that is the case
Tested in google colab, created a widget and verified that the iframe appeared
!apt-get install openjdk-11-jdk-headless

import os
from google.colab.output import eval_js
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-11-openjdk-amd64"

from google.colab import drive
drive.mount('/content/drive')

!pip install --upgrade pip setuptools wheel
!pip install deephaven-core deephaven-server
!pip install '/content/drive/MyDrive/deephaven_ipywidgets-0.2.0-py2.py3-none-any.whl'

import deephaven_server
from deephaven_server import Server
import portpicker
from google.colab.output import eval_js

dh_port = portpicker.pick_unused_port()
s = Server(port=dh_port, jvm_args=["-Xmx4g", "-Dhttp.requireHttp2=false"], dh_args={'http.requireHttp2': False})
s.start()

from google.colab import output
output.enable_custom_widget_manager()

from deephaven import empty_table
t = empty_table(10).update("x=i")

from deephaven_ipywidgets import DeephavenWidget
DeephavenWidget(t)
@jnumainville
Copy link
Collaborator

Created colab ticket: googlecolab/colabtools#3308

@mofojed
Copy link
Member

mofojed commented Jan 3, 2023

@jnumainville the GitHub issue created in colabtools hasn't seen any action yet (may just be because of the holidays). Could try making a Stack Overflow question for this as well: https://stackoverflow.com/questions/tagged/google-colaboratory

They don't seem to have a community channel or anything to ask questions that I can find :(

@jnumainville
Copy link
Collaborator

@mofojed mofojed assigned jnumainville and unassigned mofojed Jan 27, 2023
@chipkent chipkent added the devrel-watch Tickets being watched by DevRel label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working devrel-watch Tickets being watched by DevRel
Projects
None yet
Development

No branches or pull requests

4 participants