Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 641
AstrOne Avatar asked Dec 15 '17 05:12

AstrOne


People also ask

What is the difference between Jupyter Notebook and lab?

JupyterLab is the next generation of the Jupyter Notebook. It aims at fixing many usability issues of the Notebook, and it greatly expands its scope. JupyterLab offers a general framework for interactive computing and data science in the browser, using Python, Julia, R, or one of many other languages.

How do I get Ipywidgets to work in JupyterLab?

Simply install the python ipywidgets package with pip (pip install ipywidgets==7.6. 0) or conda/mamba (conda install -c conda-forge ipywidgets=7.6. 0) and ipywidgets will automatically work in classic Jupyter Notebook and in JupyterLab 3.0.

Is Jupyter Notebook better than JupyterLab?

For beginners in data science, jupyter notebook is more preferred; it only consists of a file browser and a (notebook) editor view, which is easier to use. When you get familiar with it and need more features(which we will talk about later), you can then definitely switch to JupyterLab.

What are JupyterLab extensions?

JupyterLab extensions can customize or enhance any part of JupyterLab. They can provide new themes, file viewers and editors, or renderers for rich outputs in notebooks. Extensions can add items to the menu or command palette, keyboard shortcuts, or settings in the settings system.


2 Answers

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.
like image 144
Vidar Avatar answered Oct 14 '22 03:10

Vidar


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.

like image 23
Matt Avatar answered Oct 14 '22 03:10

Matt