Predictive Hacks

AWS SageMaker and GitHub Integration

In this tutorial, we will show you how to integrate SageMaker with GitHub. There are some steps that need to be done. We will start with GitHub and the personal access tokens.

Generate a GitHub Personal Access Token

We got to the GitHub account and we click on the Settings.

AWS SageMaker and GitHub Integration 1

Then we click on the Developer Settings, then on the Personal access tokens and then on the Generate new token.

AWS SageMaker and GitHub Integration 2

Then, on the Note field, we give an explanatory name, we chose the sagemaker, for the expiration date, we chose No expiration, although it is not recommended, then we click on the repo and finally we click on the Generate token.

AWS SageMaker and GitHub Integration 3
AWS SageMaker and GitHub Integration 4

Once the token is generated, we must copy it and save it.

AWS SageMaker and GitHub Integration 5

Add a Git Repo to SageMaker

We enter the AWS Console and we go to SageMaker service. Then we go to Notebook and then to Git repositories and we click on the Add repository button.

AWS SageMaker and GitHub Integration 6

Then we land on the following page:

AWS SageMaker and GitHub Integration 7

We give a name for the AMZ SageMaker Repo, in our case we named it GitHubExample. In the Git Repository URL, we paste the GitHub repo that we want to integrate, in our case was the https://github.com/pipinho13/sagemaker-github-integration.git. Finally, we choose the Create secret, and we enter the name of the secret that we created in the previous step, i.e. sagemaker, the Username is our GitHub email and the Password is the personal secret that we saved earlier during the first step. If everything is OK you should get this message:

AWS SageMaker and GitHub Integration 8

We click on the Add repository and the repository appears in Git repositories.

AWS SageMaker and GitHub Integration 9

Integrate Git Repo with SageMaker

At this point, we can create a notebook instance that will be linked with our Git Repo. We go to Notebooks -> Notebook instances -> Create notebook instance.

AWS SageMaker and GitHub Integration 10

We give an arbitrary name to our Notebook instance, in our case PredictiveHacks and under the Git repositories section, we choose the repository that we just created, the GitHubExample.

AWS SageMaker and GitHub Integration 11

Once the Notebook instance is created, we can click on the Open Jupyter Lab.

AWS SageMaker and GitHub Integration 12

As we can see, the GitHub repo is integrated and the README.md file appears in our notebook.

AWS SageMaker and GitHub Integration 13

Let’s create a new Jupyter Notebook that we will push to the Git Repo. We have created a simple notebook called MyExample.ipynb.

AWS SageMaker and GitHub Integration 14

Push to GitHub

Under the Git section on the left, we hover on the file and we click on the plus button.

AWS SageMaker and GitHub Integration 15
AWS SageMaker and GitHub Integration 16

Finally, it asks us to add the name and the email and we are done. Then we can go to the History section, to see the changes.

AWS SageMaker and GitHub Integration 17

If we want to push these changes to the GitHub repo, we click on the circled button that we show below.

AWS SageMaker and GitHub Integration 18

Finally, if we go to the GitHub repo we should see the Jupyter notebook.

AWS SageMaker and GitHub Integration 19

Close the Notebook Instance

Do not forget to close the Notebook instance since you get charged as long as it is running.

The Key Takeaway

Whenever we work on Data Science projects, it is important to keep track of the changes by using version control. With SageMaker we are able to integrate GitHub and GitLab with our projects.

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Leave a Comment

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore