Bokeh 与 Google App Engine 兼容吗?

Is Bokeh compatible with Google App Engine?

我一直在努力解决这个问题 Udacity web dev course and wanted to try embedding a simple bokeh plot into a web page using this example。 运行 dev_appserver.py 给出错误:

ERROR    2017-01-22 14:35:30,358 wsgi.py:263]
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform
\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "C:\Users\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform
\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "C:\Users\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform
\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "C:\Users\Google Drive\Udacity web development 2017\udacit
y-cs253\bokeh_docs_example\main.py", line 2, in <module>
    from bokeh.plotting import figure
  File "C:\Users\Google Drive\Udacity web development 2017\udacit
y-cs253\bokeh_docs_example\lib\bokeh\plotting\__init__.py", line 2, in <module
>
    from ..document import Document; Document
  File "C:\Users\Google Drive\Udacity web development 2017\udacit
y-cs253\bokeh_docs_example\lib\bokeh\document.py", line 45, in <module>
    from .core.json_encoder import serialize_json
  File "C:\Users\Google Drive\Udacity web development 2017\udacit
y-cs253\bokeh_docs_example\lib\bokeh\core\json_encoder.py", line 53, in <modul
e>
    NP_MS_DELTA = np.timedelta64(1, 'ms')
TypeError: function takes at most 1 argument (2 given)
INFO     2017-01-22 14:35:30,571 module.py:806] default: "GET / HTTP/1.1" 500 -

我可能错了,但上述错误与 this 相结合表明 Bokeh 需要 NumPy>1.6.1。具体来说,json_encoder.py 似乎需要 NumPy>1.6.1.

不过。这是否意味着 Bokeh 实际上与 GAE 不兼容?

app.yaml:

runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: main.app

libraries:
- name: jinja2
  version: latest
- name: numpy
  version: "1.6.1"

Does this mean Bokeh is effectively not compatible with GAE?

我想说这是对最近版本的相当准确的评估,例如 Bokeh 0.12.4。 NumPy 1.7.1 的要求似乎也一直追溯到项目的开始。但是,曾经有一段时间 Bokeh 对 NumPy 的依赖程度较低,因此使用旧版本的 Bokeh 可能会更好,并且 1) 未安装 NumPy,或 2) 安装了较旧的 GAE NumPy。我不能肯定地说,你只需要尝试看看(YMMV)。

我可以说 Bokeh 核心团队的 AFAIK no-one 使用了 GAE,所以 no-one 知道那里的 NumPy 限制也就不足为奇了。 NumPy 版本可能会放宽以包含 1.6.1。我不确定,这需要一些调查,并且不能保证它是可行的。在时间和资源允许的情况下,我们当然可以尝试考虑它,因此我鼓励您在 Bokeh project issue tracker 上提出问题。另一个合理的行动是请求 GAE 更新他们的白名单,因为 NumPy 1.6.1 在这一点上相当古老。

我试图在 Google App Engine Flex 上使用散景服务器,它没有原始问题中提到的 numpy 版本限制。然而,即使更新了 numpy,我仍然无法让它工作。最终我在 Google 的问题跟踪器上找到了 this 10 year old open issue。看起来 Google App Engine 缺少对标准和灵活环境的网络套接字支持。由于 bokeh 服务器使用 websockets 进行通信,这可能是您看到失败的另一个原因。

Google 用户在 2018 年 7 月 23 日发表的评论如下:

Hi everyone, we are making steady progress on the Flex Websockets Beta launch and will be making it available soon.

Websockets for Standard are at least a year away. I'll continue to update here as we get more clarity on the timeline.

因此 App Engine 上的散景应用程序可能很快就有希望了。