IBM Developer

Tutorial

Integrate a Git repo with your analytics project in IBM Cloud Pak for Data

Add collaborators, navigate the UI, and create a notebook

By Amit Joglekar, Christopher Chen, Akshay Sharma

Learning objectives

This tutorial shows you how to get started integrating a GitHub repository with your analytics project in IBM Cloud Pak for Data. You'll learn about the UI, set up a personal access token to collaborate on a project, and step through a hands-on scenario to learn how to push and pull changes to and from a connected repository.

Prerequisites

To follow along with this tutorial, you need the following:

  • IBM Cloud Pak for Data
  • Account to access a GitHub repository

Estimated Time

About 15 minutes

Steps

Step 1. Create a project integrated with Git

  1. After logging into your instance of IBM Cloud Pak for Data, click on the hamburger menu on the top left and click on All projects. This will take you to the project page, allowing you to create a new project. Screenshot shows main project page

  2. Create a new analytics project. Screenshot shows creating a new analytics project

  3. Create a project integrated with a Git repository. Screenshot shows project within Git

  4. Click on New Token and a Git integration pop-up window is displayed. Select one of the project repository options from the first drop-down (GitHub, BitBucket, Azure Repos, GitLab) and create a personal access token for the project repository from the embedded link, as described in the next step. Screenshot shows new token step

  5. The embedded link will take you directly to your GitHub developer settings' personal access tokens, but in case you want to go there yourself, log into GitHub and go to Settings. Screenshot shows GitHub settings

  6. Select Developer settings from the left-hand menu. On the next page, select Personal access tokens from the left-hand menu. Click the Generate new token button in the top-right area of the page.

  7. In the New personal access token UI, select the repo checkmark, which should auto-select other indented repo options as well, and click the Generate token button at bottom of the page. Screenshot shows generating token

  8. Copy the generated GitHub token. Now go back to the browser tab for IBM Cloud Pak For Data and paste the token in the Access token field in the Git integration pop-up. Give the token a name (so you can manage it later in your IBM Cloud Pak For Data Profile > Settings > Integrations info) and click Continue.

  9. Create a Git repository and copy over the URL ending in .git and select the branch you want to collaborate on. Finally, give your IBM Cloud Pak For Data project a name and click Create. Screenshot shows creating Git repo

Step 2. Collaborating on the project

If you are a collaborator in a project that supports Git integration, you must create your own personal access token to the Git repository associated with the project to use this integration feature to share assets across the project

  1. Click on your avatar on the top right of your IBM Cloud Pak For Data home page and go to Profile > Settings, then navigate to the Git Integrations tab. Screenshot shows Git integrations from Profile

  2. Follow steps 4-6 from Create a project integrated with Git above to create a personal access token. Give it a name and continue. Screenshot shows creating personal access token

Step 3. Navigating Git-integrated JupyterLab

  1. In the upper right, next to Add to project, click Launch IDE and select JupyterLab from the drop-down. Screenshot shows adding JupyterLab

  2. Select the JupyterLab environment associated with Python 3 and launch. Screenshot shows selecting and launching JupyterLab environment

  3. Once the environment has been instantiated, you should be greeted by the launcher, where you can start a new console or create a new notebook and other files. Screenshot shows the launcher

  4. Click on the Python 3.9 Notebook button to create a new notebook. Rename the notebook from Untitled.ipynb to HelloWorld.ipynb. Write print (Hello World) in the notebook cell and press Shift + Enter to run the cell. After saving the file, you will see a green circle next to the HelloWorld.ipynb file in the file explorer panel. This green circle indicates a changed file in the environment. Screenshot shows new notebook explorer panel

  5. Go to the Git tab on the left and click the + button on HelloWorld.ipynb to stage the file.
    Screenshot shows file staging

  6. Add a comment and click Commit, then click Push to push to the repo. Screenshot shows commit Screenshot shows push

Get a breakdown of the JupyterLab git operations. And check out the JupyterLab with default Git integration (Watson Studio) documemtation for more info.

Step 4. Creating and running a notebook job within IBM Cloud Pak for Data

IBM Cloud Pak for Data can create and schedule jobs to run periodically. Here, we will create a job with the HelloWorld.ipynb.

  1. In the Assets tab within your project, click View local branch. Screenshot shows viewing the local branch

  2. In the pop-up window, click New code job. Screenshot shows starting new code job

  3. Select HelloWorld.ipynb as the asset to create a job with, then proceed to Configure the job. Screenshot shows configuring job

  4. Progress through the configurations and optionally set a schedule, then click Create. Screenshot shows creating job

  5. Click Run in the upper right, and a new run will be created and show in the Runs window. Screenshot shows job run details

  6. You can see the Hello World print result in the log of the run. Screenshot shows the print result

Step 5. Accessing security credentials with ibm-watson-studio-lib

IBM Cloud Pak for Data projects have the ability to import data assets into notebooks with the ibm-watson-studio-lib Python package. In situations where a security credential is needed, for example, with a database connection, a JSON file with credential information can be used. This allows for the security details to remain hidden and secure from being pushed to GitHub.

  1. Upload your credential file or, as shown, an SSL certificate to the project data assets. Screenshot shows uploading credentials

  2. In your notebook, import ibm_watson_studio_lib (a package that should be pre-installed within this IBM Cloud Pak for Data Python environment). Follow the screenshot below for accessing the stored data in data assets. Screenshot shows accessing stored data

The IBM Cloud Pak for Data documentation for ibm-watson-studio-lib for Python explains the usage of this package.

Summary

In this tutorial, you successfully created a project integrated with a GitHub repository in IBM Cloud Pak for Data. You learned how to add collaborators with their own personal access tokens to the repository, as well as how to navigate the UI within IBM Cloud Pak for Data to push and pull changes to the Git branch. You also created a notebook to test out these interactions to get hands-on practice.

More information

When working with GitHub, it is common to run into conflict scenarios. The IBM Cloud Pak for Data documentation for Git operations provides common scenarios and resolutions that you may run into.