BookmarkSubscribeRSS Feed
Sundaresh1
SAS Super FREQ

In an earlier tip, we shared a GitHub repository with examples to help get started with SAS Viya Workbench.  Repositories from GitHub (and similar services such as GitLab or BitBucket) are not just for examples.  They are also used for source code management, collaboration and governance.

 

To optimise your experience working with ephemeral Workbench environments,  Git repositories help you with a centralised residence for your SAS or Python (and even production or development) code.  

 

Option 1: Using the Extension

 

Let us look at two ways through which you access your code from Git repositories.  The first makes use of the built-in Visual Studio Code Git extension.  Watch the following video which shows how to use the Git extension to pull from a repository and start work in no time.

 

 

 

Some gotchas to look out for:

 

1. First, close the workspace folder in order to get the "Clone a repository" button come up on screen.  

 

2. The sign-on to GitHub (or other provider) is shown as an example.  It's an optional step, but highly likely to be encountered, especially if you're planning to access a restricted / private repository. Note that Visual Studio Code server , which operates inside a container, may not be that readily 'aware' of the connections it needs, compared to something like Visual Studio Code running on your server, therefore may require authentication when interacting with external repositories.

 

3. Remember to choose your workspace folder (also identified by the $WORKSPACE environment variable) as the place where a local copy of your repository should reside.  Since Workbench instances are ephemeral, only contents saved in the workspace folder are persisted and available later, should you decide to access the code through another Workbench instance.

 

Before you commit your changes..

 

Assuming you have made changes to your code, it's time to commit your changes.  The extension comes in useful, but, as you might notice at the end of the following video, you might run into a problem when trying to commit your changes.

 

 

 

Git config - one more gotcha

 

Wait - you notice an error stating that Git has not been configured!  Any guesses as to the reason why, 🙂 ?  Recall that Workbench instances are ephemeral, and therefore settings necessary for interacting with a GitHub repository at a 'write' level (for example, committing changes and pushing them to a repo)  require git to be properly configured.  Note that I spelt git in lowercase, indicating that this refers to the 'git' command-line utility and not the Git repository.

 

Git configuration can be easily carried out via the VS Code terminal, using a git config command.  At a minimum, the user.name and user.email fields need to be set.  Additional configuration might be required for accessing more restricted repositories.

 

 

 

# Text within braces are placeholders

git config --global user.name {your Git repo's username}

git config --global user.email {email used to access Git repo}

 

 

 

Once you've done this, it's time to push your changes, as shown in the following video.  For other useful operations, you might like to refer to tutorials such as this.

 

 

 

Option 2: Using git commands

 

Users who happen to be comfortable with the git command-line utility can also use the same in order to clone, commit, and carry out other operations on a Git repository.  The same gotchas mentioned earlier apply.  Ensure you have carried out the git config statements and that you persist your local repo in the workspace folder.  If interested, you can refer this tutorial for more git commands.

 

 

 

 

Have fun porting your code across Workbench instances of your choice.

 

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!

Discussion stats
  • 0 replies
  • 822 views
  • 3 likes
  • 1 in conversation