Use Dataproc Hub

Use Dataproc Hub to open the JupyterLab UI on on a single-user Dataproc cluster.


  1. Use Dataproc Hub to create a JupyterLab notebook environment running on a single-user Dataproc cluster.

  2. Create a notebook and run a Spark job on the Dataproc cluster.

  3. Delete your cluster and preserve your notebook in Cloud Storage.

Before you begin

  1. The administrator must granted you notebooks.instances.use permission (see Set Identity and Access Management (IAM) roles).

Open a JupyterLab Notebook UI on a Dataproc cluster

  1. Open the Dataproc Hub UI:

    1. If you have access to the Cloud Console, on the Dataproc→Notebooks instances page in the Cloud Console, click OPEN JUPYTERLAB in the row that lists the Dataproc Hub instance created by an administrator.
    2. If you do not have access to the Cloud Console, from your web browser enter the Dataproc Hub instance URL that the administrator shared with you.
  2. On the Jupyterhub page, select a cluster configuration and zone. If enabled, specify any customizations, then click Start.

    The cluster takes a few minutes to create. After the cluster is created, you are redirected to the JupyterLab UI running on the Dataproc cluster.

Create a notebook and run a Spark job

  1. On the left panel of the JupyterLab UI, click on GCS or local.

  2. Create a PySpark notebook.

  3. The PySpark kernel initializes a SparkContext (using the sc variable). You can examine the SparkContext and run a Spark job from the notebook.

    rdd = (sc.parallelize(['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'lorem'])
           .map(lambda word: (word, 1))
           .reduceByKey(lambda a, b: a + b))
  4. Name and save the notebook. The notebook is saved and remains in Cloud Storage after the Dataproc cluster is deleted.

Shut down the Dataproc cluster

  1. From the JupyterLab UI, select File→Hub Control Panel to OPEN the Dataproc Hub UI.

  2. Click Stop My Server to shut down (delete) the Jupyter server, which deletes the Dataproc cluster.

What's next