Open a notebook and create a note

In this lesson, you open a notebook and create a note.

About this task

When you start an instance group that is associated with notebooks, any notebooks that are assigned to users are started. You can also start notebooks independent of the Spark instance group start operation. Once a notebook service is started, you can launch a notebook to open the notebook service instance.

When you open a notebook, you can create notes (or notebooks within the notebook).
Note: Some notebooks such as Zeppelin and Jupyter require access to the internet to download supporting files. To create notes once you launch the notebook, ensure that your browser can connect to the internet. Check your firewall settings also to ensure permission to access sites from which files are downloaded.

In this lesson, you are using the built-in Jupyter notebook.

This lesson uses the following concepts:
Concept Description
Apache Zeppelin notebook Web-based notebook that enables interactive data analytics.
IPython Is a project that includes language-agnostic components, including notebook server, format, protocol, etc. IPython provides a Python kernel for Jupyter.
Jupyter notebook Web application that creates and shares documents that contain live code, equations, visualizations and explanatory text.

To open a notebook:


  1. From the cluster management console, go to Workload > My Notebooks & Applications, and select the Show Applications box.
    On this page, you can see the Spark batch application that you created.
    Tip: The scheduled Spark application that you created appears in this list once it has started running.
  2. Click Open Notebook > Jupyter 5.7.8 sample.
  3. Enter Admin and click Log in to gain access.
    Note: The Jupyter notebook does not automatically log out a user after a period of inactivity. As a result, the logged-in user does not have to reenter the password if the web browser window is still open. To avoid potential security issues, ensure that you always log out of the Jupyter notebook (click Logout within the notebook) or clear the web browser cache.

To create a new note (or notebook within the notebook):

  1. Create New > Spark Python (Spark Cluster Mode).
  2. Paste in the following program:
    Note: You must keep the formatting of spaces exactly or the program is invalid Python.
    from __future__ import print_function
    import sys
    from random import random
    from operator import add
    from pyspark import SparkContext
    if __name__ == "__main__":
       Usage: pi [partitions]
       partitions = 2
       n = 10000 * partitions
    def f(_):
       x = random() * 2 - 1
       y = random() * 2 - 1
       return 1 if x ** 2 + y ** 2 < 1 else 0
    count = sc.parallelize(range(1, n + 1), partitions).map(f).reduce(add)
    print("Pi is roughly %f" % (4.0 * count / n)) 
  3. Click the run cell, select below icon.

    You can see that the program has run successfully, as it computed that Pi is roughly 3.14.

  4. Click Logout to close the note.


You opened the built-in JupyterPython3 notebook and created a new note (notebook).


In this lesson, you learned how to open a notebook and created a note.

In the next lesson, you monitor and modify the sample instance group.