BookmarkSubscribeRSS Feed

GitHub + Jupyter Integration in SAS Viya for Learners 4 (VFL4)

Started ‎06-12-2024 by
Modified ‎06-28-2024 by
Views 1,678

Not-so-breaking news: GitHub is an industry standard for developers!

 

And, students, we’ll take the broad definition here and say that developers include all sorts of coders – including you and your quest to learn all things analytics. So, you’ll want to add GitHub integration as one of the many tools in your coder’s portfolio. And it's one of the many reasons to get excited about SAS Viya for Learners 4.

 

This SAS Communities Library Article covers how easily you can integrate GitHub in Jupyter using SAS Viya for Learners 4 (VFL4), our latest-and-greatest version of SAS Viya for academics. I’ll assume some basic level of familiarity with GitHub (like how to set-up and account and general navigation in GitHub). But if you’re completely new to GitHub, start with this great video and setup an account today. The rest of the article flows as follows:

  • Part 1 assumes that you already know how to use GitHub and shows you how to push changes to GitHub.
  • Part 2 takes a step back and helps you find your access token key. This section is useful if you’re still coming up to speed with all things GitHub.

 

Part I: You already know Git… and you just need to connect JupyterLab in VFL4

 

In Part 1, I’ll provide a hands-on example that I used recently to make changes to a Python notebook which reads in a file from the rdatasets package and then pushes it to CAS in SAS Viya. Not sure what those words meant? Well, no worries: enjoy the (bullet-point-style) ride!

 

Before launching right into it, I’ll give you a disclaimer: don’t follow the steps as exactly outlined below. Why? Because it’s my file… and my edits. Create your own – or you’ll likely get access errors. Seriously 😊

 

Preambles aside, here we go:

  • I’ll start by establishing a GitHub connection in JupyterLab in SAS Viya for Learners 4. The repo that I want to pull is https://github.com/lincolngroves/RandomData-RandomThoughts.git which is found, more generally, in my project here.
  • After getting settled in JupyterLab in VFL4, four clicks get me to where I need to be.  Start by clicking the Git button on the left pane. Then select Clone a Repository, and, in the Clone a repo Window, paste the URL of the repository. Finally, select Clone when it’s cloning time. Those clicks in order:
LGroves_0-1718213726422.png

 

  • If all goes according to plan, you’ll see the folder added in the File Browser. My folder is RandomData-RandomThoughts. And it’s here:
LGroves_1-1718213726429.png

 

  • Another sign that you’re on the right path is this happy message in the lower-right corner:
LGroves_2-1718213726430.png

 

  • Next, drill down into the Git folder to examine the contents. If this is a new folder, it’s also a great place to upload/move the Jupyter Notebook you want to work on in the local Jupyter environment
  • My example:
LGroves_3-1718213726435.png

 

  • And you can upload new files to that local GitHub folder, by clicking here:
LGroves_4-1718213726438.png

 

  • Open a Jupyter Notebook and edit away, as needed. My example is Python Dataframe to CAS Data Sets.ipynd. I’ll use Save (Ctrl+S) when I’m done:
LGroves_5-1718213726453.png

 

  • Big important note: you’ve only saved your work to the local version of Jupyter – which is an impermanent environment – meaning it won’t exist after your sessions ends. This is just how VFL4 needs to be configured to adhere to user privacy policies (otherwise, it’s a shared environment and we’d run afoul of privacy issues). So, I need to commit the changes to make them permanent. A couple of clicks get me there.  I’ll start with a click on the Git icon to see all the action staged in the current repository:
LGroves_6-1718213726461.png

 

  • For our next trick, we can move the notebook under the Changed section to Staged:
LGroves_7-1718213726465.png

 

  • Forget that checkpoint file because – to me – it’s not super helpful. Instead, click the file in the Staged section. Under Summary, add a few details about what you’ve done. My example:
LGroves_8-1718213726470.png

 

  • Click COMMIT. The following dialog box appears:
LGroves_9-1718213726471.png

 

  • Enter your info. Name can just be a first name.  Use the email associated with your GitHub account (but, honestly, it really doesn’t matter because these are just local changes). Then press OK. Look out for another happy sign in the lower right corner:
LGroves_10-1718213726472.png

 

  • Think you’re done?  Nope!  Sorry!  The changes were committed to the local version of the Git repo in Jupyter only.  But… we really want to push it up to the external GitHub site, which is a remote connection in this context. So, from the top menu, find Git >> Push to Remote:
LGroves_11-1718213726481.png

 

  • To push to GitHub, you’ll need Git credentials. (See Part II for instructions on creating a personal access token.) Here’s an example:
LGroves_12-1718213726483.png

 

  • After putting in your validated credentials, and pressing OK, you’ll see a note in the lower-right hand corner if your push has been successful. 
LGroves_13-1718213726484.png

 

  • And you can always check the website to ensure that it was. My example:

 

LGroves_14-1718213726499.png

 

  • Success!

 

Part II: You (kind of) know Git, but need help setting up the personal access token

 

Alright, perhaps you’re only familiar with GitHub in the sense that it’s a great tool for learning – and you use it only when you need to pull files down from GitHub to use in VFL.  That’s cool.  I was there.  And, actually, that was me like 10 minutes ago (nothing prompts learning like writing a SAS Communities article!).

 

This section will walk you through how you can set up a personal access token, which will allow you to push changes to files + data + more to GitHub for everyone to examine.  And it’s a very powerful tool indeed.  Let’s get started:

LGroves_15-1718213726538.png

 

  • Next, find the Settings section:
LGroves_16-1718213726547.png

 

  • Look at all those settings available.  Whoa!  Scroll down and find < > Developer settings on the left side:
LGroves_17-1718213726551.png

 

  •  Still on that left-hand side, expand on Personal access tokens.  Select Tokens (classic):
LGroves_18-1718213726556.png

 

  • Click on Generate new token >> Generate new token (classic):
LGroves_19-1718213726565.png

 

  • While you can choose a variety of options for your token, I’m keeping it simply in this example. Moreover, for security purposes, I’ll choose a token that expires after a day so that you’re not tempted to use it 😊
  • Under Note, I’ll put VFL4 Upload Illustration.  Choose a longer Expiration, but I’ll set mine to a day.  Those two steps:
LGroves_20-1718213726569.png

 

  • Under Select scopes, select only repo. This keeps it simple:
LGroves_21-1718213726574.png

 

  • Finally, scroll all the way to the bottom and then click Generate token:
LGroves_22-1718213726581.png

 

  • The token is now created!  Here’s my example:
LGroves_24-1718214635765.png

 

  • Remember, that’s my token – and it no longer works 😊  Additionally, please read that important note in blue: Make sure to copy your personal access token now. You won’t be able to see it again!  Seriously, it’s gone.
  • Now you can use that personal access token with your username in your Git credentials, all the way back in this step from Part 1:
LGroves_25-1718214681194.png

 

Happy Git’n!

Version history
Last update:
‎06-28-2024 12:33 PM
Updated by:
Contributors

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags