Really confused with Jupyter Notebook, Lab, extensions, and ipywidgets

你说的曾经没有我的故事 提交于 2020-01-01 08:24:27

问题


I want to create an interactive JupyterLab Notebook application, and I need to create a series of custom Widgets. So I started looking into this matter, and the more I look the more confused I become. To make things simple I will ask a bunch of simple questions:

  1. One of the most common ways to use widgets on Jupyter Notebooks is to use the ipywidgets library. Right?
  2. Unlike the classic Notebook, the Notebook of JupyterLab cannot render JavaScript directly. As a result, the tutorials about custom widget creation in the ipywidgets docs are impossible to run on JupyterLab. Right?
  3. If one wants to run JavaScript on the Notebook of JupyterLab she or he will have to do it through an extension. In case of ipywidgets, one will have to install @jupyter-widgets/jupyterlab-manager. Right?
  4. If you want to write a custom widget using the ipywidgets library, there are two GitHub projects that you could use as a starting point: widget-cookiecutter and widget-ts-cookiecutter. To my understanding, the former is based on JavaScript while the latter on TypeScript. Also, the first appears to be inactive for quite some type, while the second is more active. Is the JupyterWidgets team planning to focus on TypeScript? Which one should I follow?
  5. The cookiecutter projects do not really have a documentation. I am really confused and struggling to understand their code. Sure, I can copy-paste them and start messing around until I figure out how the whole thing works and what are the "hooks" or "entry points" in the code, but I would really appreciate if someone could give me some additional pointers.
  6. Is the JupyterWidgets an "official" project of the Jupyter project? Given the very small number of members in the project I wonder how safe is to base my work on ipywidgets. Keep in mind that the "DeclarativeWidgets" project has abandoned long time ago.
  7. Are there other libraries that implement more widgets than the ones found in ipywidgets and also run on JupyterLab?
  8. I want to create a Web application for server-side data processing. My initial goal was to create an app/service that does not expect from the user to do any coding, and performs everything through the use of html/JavaScript widgets. That could be implemented using an Angular/React front-end and a Python/Django/Flask back-end. However, later on, I realised that there are cases where the user may want to do some additional custom/arbitrary processing on the server. This is why I considered JupyterLab. I wonder if it would be best and if it is possible to just create, for example, a normal Angular/Python font/back-end, and somehow wrap this up in a JupyterLab extension that will provide a mechanism to access the data from this app/service and bring it to the notebook for further processing.

Thanks in advance


回答1:


In general, stackoverflow question should try to only ask one question at the time. That being said, I'll try to answer the questions as best I can:

  1. ipywidgets is the main way, yes. It is what people mean when they talk about notebook widgets.
  2. There is an issue tracking general JS in jupyterlab on the jupyterlab repo.
  3. @jupyter-widgets/jupyterlab-manager is the widgets for jupyterlab, yes, but you will still need the python code in ipywidgets. See http://ipywidgets.readthedocs.io/en/stable/user_install.html for details.
  4. While it is true that one is JS and the other TS, the TS one also has all the bells and whistles. It is therefore also more complex. The JS one is more bare-bones and might therefore be better for understanding the most important bits.
  5. I agree that both could do with better documentation! I've been meaning to do this for a while. The best way to make this happen is probably to open issues with specific questions on the respective repositories, and suggesting the explanation go in the README or similar. That way you can ensure that your pain-points gets addressed.
  6. Given the large user base of widgets, I would consider it safe. While the bus factor isn't very high, people tend to step up if there is a drop in maintainers.
  7. Yes, but using widgets for jupyterlab is still slightly high maintenance both for developers and users.
  8. What you might want to study is Comms (http://jupyter-notebook.readthedocs.io/en/stable/comms.html), which is what widgets use under the hood for its synchronization. This is lower level though, so you will have to judge which is most suitable for you.



回答2:


First of all, remember that JupyterLab is not stable yet and internal API are still changing quite a bit. The biggest part of your frustration is trying to find information about a project that is changing every week (should stabilize early 2018 for reference).

This lead to minimal effort writing documentation and example for users, as anyway the documents will be wrong a week later. So your confusion and lack of activity is normal for now.

Once Lab stabilizes and the IPywidget team start porting everything you should see an improvement.



来源:https://stackoverflow.com/questions/47826117/really-confused-with-jupyter-notebook-lab-extensions-and-ipywidgets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!