manzt/pygv

Use on Google Colab?

cmdcolin opened this issue · 4 comments

Hello:)
It is great to see this project.

I was trying to see if it worked on Google Colab but it seemed to give an error
screenshot

image

ERROR:    [Errno 99] error while attempting to bind on address ('::1', 43081, 0, 0): cannot assign requested address

is this expected? i was interested in the servir code cause that worked seemlessly locally in the jupyter lab notebook

random other note: i think this repo is missing a license

is this expected? i was interested in the servir code cause that worked seemlessly locally in the jupyter lab notebook

Thanks. This should be working. I ran into it the other day and wonder if Colab has changed something. Ideally, we would use anywidget to send the data but servir is a quick workaround to expose a background webserver to the client. However, as you are noticing, there are more issues that arise with this due to a need to separately configure the web sever for different environments. "easy" locally, and a nightmare for "remote" Jupyter/Colab.

If we used the Jupyter websocket (via anywidget), we could reuse this channel for better consistency across all environments.

random other note: i think this repo is missing a license

oops, just added. Thanks for pointing this out!

For context, Google Colab (historically) has used a Service Worker in the front end to authenticate and proxy HTTP requests to http://localhost in the google notebook to the backend kernel. This behavior is not documented and I'm guessing there is some change.

Update: I'm able to get servir working by starting the Provider on host=0.0.0.0 but then the URL provided to the front-end needs to be localhost to hook into the Service Worker behavior. Here's a hacky workaround, but range-requests don't seem to be working.

!pip install --quiet pygv
!wget https://raw.githubusercontent.com/sehilyi/gemini-datasets/master/data/UCSC.HG38.Human.CytoBandIdeogram.bed
import pygv

pygv._api._PROVIDER.start(host="0.0.0.0") # start background server on `0.0.0.0` instead of `localhost`

pygv.ref("hg38")
pygv.locus("chr1")
track = pygv.track("UCSC.HG38.Human.CytoBandIdeogram.bed")
track.url = track.url.replace("0.0.0.0", "localhost") # change URL given by servir to `localhost` for front end 🙄
pygv.browse(track)

More in-depth discussion: higlass/higlass-python#144

excellent, thanks for checking that out! I am really curious what something like #1 could look as well...