Skip to content

JupyterLab

Dae Song Park edited this page Sep 26, 2022 · 35 revisions

◀️ Integrated Tools 🔗 VS Code ▶️


JupyterLab is a browser-based IDE for running Python and R programs in Jupyter NoteBook. PadoGrid provides the following commands for integrating PadoGrid workspaces with JupyterLab workspaces.

Command Description
start_jupyter Start Jupyter Notebook server in the current RWE JupyterLab workspace
open_jupyter Open the current RWE JupyterLab workspace
show_jupyter Display Jupyter Notebook server status
stop_jupyter Stop Jupyter Notebook server

Installing JupyterLab

To install JupyterLab, please follow the instructions provided in the following link.

Install JupyterLab

You can verify the installation by running the jupyter executable. The PadoGrid Jupyter commands will fail if the jupyter executable is not found.

Running JupyterLab in PadoGrid

Running Locally

If you are running PadoGrid locally on your PC, then you can run open_jupyer to open JupyterLab in the browser. This command starts the JupyterLab server if it is not running and then launches the browser with PadoGrid integrated. The screen will look similar to the example shown below. The browser display is divided with the workspace's README.md file if exists and three (3) terminals.

# Start Jupyter server on the default port 8888 if it's not running and then launch browser
open_jupyter

# Start Jupyter server on the specified port and then launch browser
open_jupyter -port 8889

Example Output:

Saved workspace: /Users/dpark/.jupyter/lab/workspaces/labworkspacesrwe-bundles-5382.jupyterlab-workspace

Notebook server started.
   http://localhost:8888/lab/workspaces/rwe-bundles

Jupyter Workspace in Browser

Running Remotely

You can use start_jupyter to launch the Jupyter Notebook server without opening the browser. This command is useful if your workspace is remotely distributed and you are not able to launch the browser from there. Once the Jupyter Notebook server is started using this command, you can launch the browser from your local machine and enter the Jupyter Notebook server URL in the browser to remotely access the PadoGrid workspace.

# Start Jupyter Notebook server on the default port 8888
start_jupyter

# Start Jupyter Notebook server on the specified port
start_jupyter -port 8889

Example Output:

Notebook server started.
   http://localhost:8888/lab/workspaces/rwe-bundles

The workspace in the Jupyter terminals may be incorrect due to JupyterLab limitations. Switch
into the current workspace by running the following command in each Jupyter terminal.

   switch_rwe rwe-bundles/bundle-hazelcast-4-k8s-cdc_demo

✏️ The open_jupyter command opens each terminal in the current workspace directory but the workspace context is set by the login shell script, i.e., .bashrc or .bash_profile. You must explicitly run the switch_rwe command in each terminal to switch into the current workspace as described in the open_jupyter output. You can copy/paste the command output in each Jupyter terminal.

The Jupyter Notebook server URL can be obtained by running show_jupyter which displays all running servers with their URL information.

# Display running servers
show_jupyter

Example Output:

Currently running servers:
http://localhost:8888/?token=f169c6368999c83df5179fdece046d136040668e1204af21 :: /Users/dpark/Padogrid/workspaces/rwe-bundles

Stopping Jupyter

You can stop a specific Jupyter Notebook server or all servers with stop_jupyter.

# Stop the server running on the default port 8888
stop_jupyter

# Stop the server running on the specified port
stop_jupyter -port 8889

# Stop all servers
stop_jupyter -all

Example Output:

Jupyter notebook server stopped: [8888]

Installing and Running JupyterLab on AWS EC2

You can install JupyterLab on any of PadoGrid installed EC2 instances and remotely manage PadoGrid using your browser. Once you have created a VM workspace with AWS EC2 instances as described in Geode on AWS EC2 and Hazelcast on AWS EC2, follow the instructions below to install and run JupyterLab.

# ssh into one of the EC2 instances
cd_workspace
ssh -i mykey.pem ec2-user@3.19.14.241

From the EC2 instance install JupyterLab:

# Amazon Linux, Red Hat
sudo yum install python3-pip

# Amazon Linux, Red Hat
sudo apt install python3-pip

pip3 install jupyterlab

Create a self-signed certificate to be used for SSL.

switch_workspace myworkspace
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout .mycert.pem -out .mycert.pem
chmod 400 .mycert.pem

Encrypt password that you will be using in the browser to login to JupyterLab.

ipython

from IPython.lib import passwd
passwd()

quit()

Output:

Python 3.9.7 (default, Sep 16 2021, 08:50:36)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.29.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from IPython.lib import passwd

In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:75f4df39063f:a7f26527cfb94b5fafba0e11d380b065ea5791b6'

In [3]: quit()

Generate and update a Jupyter server config file. Use the encrypted password for c.ServerApp.password as shown below.

jupyter server --generate-config

cat <<EOF >>  ~/.jupyter/jupyter_server_config.py
c = get_config()
c.ServerApp.certfile = u'/home/ec2-user/Padogrid/workspaces/rwe-hazelcast/ws-aws-hazelcast/.mycert.pem'
c.ServerApp.ip = '*'
c.ServerApp.password = u'sha1:75f4df39063f:a7f26527cfb94b5fafba0e11d380b065ea5791b6'
c.ServerApp.port = 8888
EOF

Start JupyterLab

# The '-import' option is introduced in PadoGrid v0.9.21 to import workspace
# templates. If this option is not specified then the initial web page defaults
# to a blank page.
start_jupyter -import

Use the public IP address of the EC2 instance to login from your browser. For our example, the public IP address is the IP address we used to ssh into the EC2 instance, i.e., 3.19.14.241.

https://3.19.14.241:8888/

Installing JupyterLab on Vagrant VM

  1. Create a pod with enough memory for the primary node. This example allocates 4 GiB on the ubuntu/focal64 Vagrant box, which has the latest Python3 version installed.
create_pod -quiet -box ubuntu/focal64 -avahi -pod mypod -pm 4096 -dir /Users/dpark/Padogrid/products/linux
  1. Install Linux products such as Java, GemFire, Hazelcast, Redis, etc. in /Users/dpark/Padogrid/products. You can download and untar them in that directory.

  2. Build pod

switch_pod mypod
build_pod
  1. ssh into pnode.local
ssh vagrant@pnode.local
  1. From pnode.local, install pip, install and start JupyterLab
# Install pip
sudo apt install python3-pip

# Install JupyterLab which requires jinja2>=3.0.3
pip install jinja2==3.1.2
pip install jupyterlab

# Add `/home/vagrant/.local/bin` to `PATH`
echo "export PATH=\"/home/vagrant/.local/bin:\$PATH\"" >> ~/.bashrc
export PATH="/home/vagrant/.local/bin:$PATH"

# Start JupyterLab
# Specify '-import' to import the PadoGrid workspace datashboard
start_jupyter -import
  1. Enter the URL in the browser

URL: http://pnode-local:8888/lab/workspaces/rwe-bundles


◀️ Integrated Tools 🔗 VS Code ▶️

Overview

Operations

Tools

Platforms

Clouds

Pado

Geode/GemFire

Hazelcast/Jet

ComputeDB/SnappyData

Coherence

Hadoop

Kafka/Confluent

Mosquitto

Redis

Spark

Clone this wiki locally