Colabs - Bokeh server

Question - Trying to us Google Colabs with Bokeh server. I’ve downloaded an example file bokeh/examples/app/ohlc at 2.0.2 · bokeh/bokeh · GitHub. I can not get it to run on Colabs. Runs fine under jupyter notebook in localhost:5006.

I’ve tried:

from google.colab.output import eval_j
eval_js(‘google.colab.kernel.proxyPort(5006)’) + ‘/stock’

then run: bokeh serve --show stock.py

I get the following:
2020-04-26 18:47:17,624 Starting Bokeh server version 1.0.4 (running on Tornado 4.5.3)
2020-04-26 18:47:17,626 Bokeh app running at: http://localhost:5006/stock
2020-04-26 18:47:17,626 Starting Bokeh server with process id: 775
2020-04-26 18:47:21,888 200 GET /stock (127.0.0.1) 105.64ms
2020-04-26 18:47:22,274 200 GET /static/js/bokeh-widgets.min.js?v=68fceb4be2f3d6410ff2d7704c8b87cf (127.0.0.1) 2.61ms
2020-04-26 18:47:22,371 200 GET /static/js/bokeh-gl.min.js?v=70e18d8dcea09947c12764bf85ec76a0 (127.0.0.1) 0.97ms
2020-04-26 18:47:22,412 200 GET /static/js/bokeh.min.js?v=afab3eba5b3a72c05610143940e03c8e (127.0.0.1) 1.55ms
2020-04-26 18:47:22,491 200 GET /static/js/bokeh-tables.min.js?v=02bdadb2c698bc2855a4d4a69c163821 (127.0.0.1) 0.99ms
2020-04-26 18:47:22,580 200 GET /static/css/bokeh.min.css?v=4c253f78f16b7d5d0c9d1df8062c7f4c (127.0.0.1) 0.90ms
2020-04-26 18:47:22,675 200 GET /static/css/bokeh-tables.min.css?v=86c18b0b1fd30cdbc124e60cb9452e73 (127.0.0.1) 0.77ms
2020-04-26 18:47:22,791 200 GET /static/css/bokeh-widgets.min.css?v=6f280acb818327130a8c244ce05fd10d (127.0.0.1) 0.82ms
2020-04-26 18:47:23,851 404 GET /favicon.ico (127.0.0.1) 0.64ms

Any and all help with be greatly appreciated.

AFAIK this is a non-starter on Colab at present, for the same reason as discussed here:

TLDR; Google Colab does not currently allow arbitrary websocket or notebook comms to be opened, making advanced Bokeh features unusable there. We can’t do anything about that on our end, it will be up to Google to make changes on their end (which they possibly will, but I have no idea of their timeframe).

As an alternative for now you might consider MyBinder, which I know folks have gotten to work:

Thanks for the quick response. I did have it running at one point on colabs, but must had been a wired connections. Just lost it and can get it to repeat.

Thanks agian…

Well, I know for certain notebook comms cannot currently work. I would be happy to be proven wrong about Bokeh server apps run from colab, but I don’t know how that might be unless they offer some options for opening up websockets that I don’t know about. But Bokeh server 100% requires a websocket connection—after an initial handhsake, all Bokeh server comms immediately go over a websocket.

Would switching from web sockets to long polling help in this situation?

Perhaps, I don’t have any personal experience implementing anything using long polling. It’s seems a given that plain JSON would have to be used throughout and that the efficient binary protocol, which I consider important distinguishing feature for Bokeh, would not function. I’d say exploring this is definitely not anything that is anywhere on my own priority list. But, I am interested to elevate the Bokeh protocol to be useful more on its own, e.g. independent of Tornado. I had not imagined that including non-socket transport layers, but I suppose there is no reason it couldn’t. So, I’d be happy to help offer guidance to anyone who wanted to experiment with an option (or demonstration) of using the protocol via long polling.