Since the SAS Viya Stable release 2022.09, you can use the SAS Viya Command Line Interface (CLI) to create a Git publishing destinations. A Git publishing destination allows you to publish a SAS model, decision or rule set to a Git repository. The SAS Viya CLI is faster and less complex than using Python to call SAS Viya REST APIs. Because of these factors, in a few minutes, you will be ready to publish models from SAS Model Manager, or decisions and rule sets from SAS Intelligent Decisioning to any Git repository on GitHub, Bitbucket, Azure Repos, GitLab, etc. Read the post to learn how to use the SAS Viya CLI to create Git publishing destinations.
Models and decisions are stored in a Git repository, which sits outside SAS Viya. Specifically for SAS Viya cloud deployments, it helps SAS customers decouple development and promotion, share with a wider audience the SAS models or decisions code, while reducing cloud costs.
From the Git repository, you can deploy the published models or decisions to SAS Cloud Analytics Service (CAS) or SAS Micro Analytic ...). There, you can score them in batch or using a REST API. These two destinations can be in the same SAS Viya environment, or in a different environment, for example test, staging, production, etc.
After Michael Goddard mentioned in his post Creating model publishing destinations using the SAS Viya CLI : “Using the SAS Viya CLI is a much better approach and hides the complexity of working with the REST API”, I decided to give the SAS Viya CLI a go for a Git destination.
The video summarizes the approach.
It took less than five minutes to define a Git publishing destination, which is great.
First of all, there are some prerequisites for your software and environment.
I am using GitHub as the Git repository flavor. If you are using GitHub, you must:
Points two and four are detailed in How to Publish SAS Decisions to Git: Required Configuration.
On a client machine, for example a Linux Virtual Machine:
You can use the sample code provided to define the publishing destination. Adapt the variables to your context:
# Gather SAS Viya Variables
export GELENV_NS=gelenv # your SAS Viya Namespace
NS=$GELENV_NS
echo $RG
INGRESS_FQDN=${RG}.gelenable.sas.com # this is your SAS Viya URL without the https://
DOMAIN_NAME=GitHubDomainCLIGamma # credential domain name that will be created
DOMAIN_DESC=GitHubDomainCLIGamma # credential domain description
DEST_NAME=GitHub # publishing destination name
DEST_DESC=GitHub # publishing destination description
CODE_GEN=MAS # From Git you can later deploy to a MAS or CAS publishing destination. Code generation can be MAS or CAS.
# Gather GIT Variables - from your Git repository
GITHUB_REPO_URL= fill_in_here
# e.g., GITHUB_REPO_URL=https://github.com/bteleuca/sas-viya-az-devops.git
GITHUB_USER= fill_in_here
# GITHUB_USER Your GitHub user, typically after https://github.com/ e.g., GITHUB_USER=bteleuca
GITHUB_EMAIL= fill_in_here
# GITHUB_EMAIL=Your_GitHub_Account_email
GITHUB_BRANCH= fill_in_here # e.g. main
# Secret
GITHUB_PAT=fill_in_here
# e.g., GITHUB_PAT=ghp_z*jc2y*Z*8bG91Y*P9bSJy8MZ8j*Ne3h*uHu
# Check the variables
printf "\n We need the following variables for the CLI \n "
echo "SAS Viya URL: https://$INGRESS_FQDN"
echo "SAS User Name: ${SASUSER}" # the SAS identity user or group creating the publishing destination
echo "SAS User Password: ${AZUPW}" # the credential for the SAS identity
echo "SAS Domain Name: ${DOMAIN_NAME}"
echo "SAS Domain Description: $DOMAIN_DESC"
echo "Git User Name: $GITHUB_USER"
echo "SAS Publishing Destination Name: $DEST_NAME"
echo "SAS Publishing Destination Description: $DEST_DESC"
echo "Git User Email: $GITHUB_EMAIL"
echo "Git Repository URL: $GITHUB_REPO_URL"
echo "Git Repository Branch: $GITHUB_BRANCH"
echo "Code Generation Mode MAS or CAS: $CODE_GEN"
#echo "Git Personal Access Token: $GITHUB_PAT"
echo "Git Personal Access Token: well... it's secret..."
# Login with the sas-viya cli. Profile {SAS_CLI_PROFILE} has already been created.
cd ~
export SAS_CLI_PROFILE=${GELENV_NS:-Default}
export SSL_CERT_FILE=~/.certs/${GELENV_NS}_trustedcerts.pem
sas-viya -k auth login --user sassmth --password ********** # mask
# List the variables used by the SAS VIYA CLI
sas-viya -k --profile ${SAS_CLI_PROFILE} models destination createGit --help
# create the Git publishing destination
## all code on one line ; descriptions must be double quoted
sas-viya -k --profile ${SAS_CLI_PROFILE} models destination createGit --name ${DEST_NAME} --description "${DEST_DESC}" --remoteRepoURL ${GITHUB_REPO_URL} --userEmail ${GITHUB_EMAIL} --gitUserId ${GITHUB_USER} --gitBranch ${GITHUB_BRANCH} --gitAccessToken ${GITHUB_PAT} --codeGenerationMode ${CODE_GEN} --userName ${GITHUB_USER} --identityType user --identityId ${SASUSER} --credDomainID ${DOMAIN_NAME} --credDescription "${DOMAIN_DESC}" --localRepoLocation " /mmprojectpublic"
After you run the code, you can check in SAS Environment Manager the Git destination properties.
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
If you would publish from SAS Model Manager, the decision tree model QS_Tree1 to the recently created Git publishing destination, you would see:
The Git repository used as a publishing destination will contain several folders and files. The folders are a combination of project name, model version and model name.
If you would publish from SAS Intelligent Decisioning, the SAS decision autoAuctionDec to the recently created Git publishing destination, you would see:
The decision is made of a SAS model, several rule sets and code files. The Git repository used as a publishing destination will contain several folders and files.
If you are curious what is in the published files, see How to Publish SAS Decisions to Git: Published Files.
Since the SAS Viya Stable release 2022.09, you can use the SAS Viya CLI to create the Git publishing destination. The CLI simplifies greatly the task for the end user. Because it is now less complex, we should more people publishing models and decisions (or rule sets) from SAS Viya to a Git repository.
From the Git repository, you can deploy the published models or decisions to CAS or MAS, where you can score them. These two destinations can be in the same SAS Viya environment, or in a different one (test, staging, production).
Models and decisions are stored in a Git repository, which sits outside SAS Viya. Specifically for SAS Viya cloud deployments, it helps SAS customers decouple development and promotion, share with a wider audience the SAS models or decisions code and reduce cloud costs.
Thank you for your time reading this post. If you liked the post, give it a thumbs up! Please comment and tell us what you think about post content. If you wish to get more information, please write me an email.
Find more articles from SAS Global Enablement and Learning here.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.