Click here to Skip to main content
15,867,594 members
Articles / Programming Languages / C#

Jupyter.net: A Windows Application for Interactive Computation using Jupyter

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
21 Jun 2020CPOL4 min read 9.6K   277   10  
Presentation of the Jupyter.net application
In this article, I will introduce Jupyter.net: Windows standalone application written in C# for doing interactive computation using a Jupyter kernel.

Introduction

In this article, I am going to introduce Jupyter.net: a Windows standalone application written in C# for doing interactive computation based on the Jupyter framework. It can be considered as a simplified version of the Jupyter Notebooks.

The Jupyter framework consists mainly of:

  • a communication protocol to put in communication a kernel, which is responsible for running program code, and a frontend that allows the user to enter code, see the results, save the code in a file, etc.
  • a Notebook file format, to store in a file code, execution results, additional notes and metadata. The rich structure of this format allows to store even images, sounds and potentially any kind of information.
  • a Python kernel.
  • The Jupyter notebook: an open source, general purpose web fronted for Jupyter. It can be considered the “official” Jupyter GUI.
  • JupyterLab: a newer and enhanced version of Jupyter notebook
  • Jupyter console: a simple command line frontend for Jupyter

There are also other third party Jupyter frontends, like:

  • Nteract: a desktop general purpose desktop application to create, edit, execute Jupyter notebooks
  • CoCals: a web based Jupyter frontend, specialized in data science
  • Spyder: a desktop application for data science, based on Jupyter

The Jupyter architecture is very general, and combining the right kernel with the right frontend, it can be used for many and varied things. Spyder is a good example of how this architecture can be used to create a powerful tool for data analysis.

There are kernels available for any programming language (https://github.com/jupyter/jupyter/wiki/Jupyter-kernels) and the available frontends are generally enough to be used in various contexts. Jupyter.net however can be used as a base to create more specific GUI.

Finally, Jupyter.net is based on the library described here: jupyter.net Client: A C# Library to Interact with Jupyter Kernels. Although not necessary, I suggest you read the article.

Background

To use Jupyer.net, it's preferable to have basic knowledge of Python. To understand the code, you need a discrete knowledge of C# and WPF.

Installing Jupyter.net

The application assumes that Python and the Jupyter framework are installed properly on your computer.

You can download the Python installer from this link. During the installation, select the option “Add Python 3.X to PATH”.

Once Python has been installed, you can install the Jupyter framework by executing the following command on a command prompt: python -m pip install jupyter.

To test the Jupyter installation, you can run the command jupyter console. The command line Jupyter interpreter should open, and it should connect to a Python kernel and let you execute Python code.

Once Python and Jupyter are installed properly, you can just download the JupyterNet.zip file, uncompress it and run JupiterNet.exe.

Using Jupyter.net

Once the application has started, it looks for a Python kernel and runs it.

If the application fails to find the Jupyter framework, it will ask for the location of python.exe. If you have more than one Jupyter kernel installed, the application will ask to choose one.

Once the initialization is completed, you’ll see the screen below:

Image 1

The text Python 3 | Idle on the status bar confirms that a Python kernel has been started successfully.

You can then enter any code on the code bar and execute it by pressing Enter. If you press Alt+Enter, the code is interpreted as a comment and inserted on the notebook, but not executed.

If you need to enter code longer than one line, you can press the button Multine mode or press F3.

When entering code, you can press Ctrl+Space to show a menu of suggestion to complete the current statement.

If you want to interrupt the current computation, press the button Interrupt.

To modify an existing cell, double click on it, or select it and press Edit.

Image 2

Application Architecture Overview

The application architecture follows Model-View-ViewModel (MVVM) pattern.

Image 3

The main classes of the application are:

NotebookEditorVM: It is the main view model for the application. It contains the current notebook, the commands available to the users and additional status information.

Mainwindow.xaml: It is the view of the application, written in XAML and linked to the view model NotebookEditorVM using data binding.

JupyterClient is the class that contains the methods to communicate with the kernel. It is described in this article: jupyter.net Client: A C# Library to Interact with Jupyter Kernels

NotebookVM: It is a viewmodel for the open notebook. At the moment, there can be just one notebook open at a time.

NotebookVM transforms the data contained in a Notebook class in order to be visualizable in a ListBox object. Note that a Notebook is a hierarchical object because each input node can contain many output nodes as children. This structure is “flattened” by the NotebookVM in a simple list of nodes, which are instances of one of the following CellVM subclasses:

  • InputcellVM
  • TextCellVM
  • ImageCellVM

The NotebookVM and CellVM classes also keep track of the cell execution status. Each cell can be in one of the following states:

  • NotStarted
  • Running
  • Completed
  • Error

History

  • 21st June, 2020: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Unknown
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --