How to Deploy SAS Decisions from Git to MAS
- Article History
- RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
You can use the decisiongitdeploy SAS Viya Command Line Interface plug-in to deploy decisions or rule sets from a Git repository to SAS Viya. The decisions can include SAS models in their composition. You can deploy the decisions as SAS Micro Analytic Service (MAS) modules in any number of SAS Viya environments. When you deploy SAS decisions to MAS, your decision can be scored through a REST API. You can call the REST API from any application, programming language or script.
Publish to Git - Deploy from Git
The deployment process, which is the focus of this post, is highlighted by the orange block in the diagram.
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
Publish to Git
A series of posts have already discussed the publishing from SAS Viya to a Git repository:
- How to Publish SAS Decisions to Git: Published Files looked at the publishing and the files created.
- How to Publish SAS Decisions to Git: Publishing Destination created a Git destination.
- How to Publish SAS Decisions to Git: Required Configuration detailed the SAS Viya and Git configuration.
- How to Integrate SAS Intelligent Decisioning with Git gave an overview of the process.
Deploy from Git
The deployment process:
- Make accessible the Git files containing the published decisions to the SAS Viya Command Line Interface (CLI).
- Select the publishing destination.
- Use the decisiongitdeploy SAS Viya CLI to deploy these decisions, to the SAS Viya publishing destination.
The decisiongitdeploy SAS Viya CLI
In SAS Viya, a command-line interface (CLI) is a user interface to the SAS Viya REST services. In this interface, you enter commands on a command line and receive a response back from the system. With the decisiongitdeploy CLI you can deploy decisions and rule sets from a local Git repository to a SAS Micro Analytic Service (MAS) environment or to a SAS Cloud Analytic Services (CAS) environment. You must publish the decisions and rule sets to a Git publishing destination, then, copy them into your local Git repository before you use the CLI. The decisiongitdeploy CLI, was first released in the SAS Viya 2021.2 (November 2021) long term support.
Make Accessible the Git Files to the SAS Viya CLI
To access the files from your Git repository, an easy option is to clone the Git repository. If you decide to clone a private GitHub repository with SAS Studio:
- Create a Git profile.
- HTTPS can be used as an authentication method.
- The GitHub Personal Access Token acts as a password.
- Choose a folder for the cloned repository. The example in the video uses a folder called gitDeploy.
- Chapters
- descriptions off, selected
- captions settings, opens captions settings dialog
- captions off, selected
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
This is a modal window. This modal can be closed by pressing the Escape key or activating the close button.
Select the Publishing Destination
A Micro Analytic Service must exist prior to publishing. In most SAS Viya deployments, a MAS destination is created by default.
Use the decisiongitdeploy SAS Viya CLI
To deploy the decisions from the cloned files, you must use the SAS Viya Command Line Interface (CLI). The base assumption is that you have already installed the SAS Viya CLI.
Create a SAS Viya CLI Profile
First, you need to create a SAS Viya CLI profile. In our environment, the required script would look like:
# Get namespace and host
kubectl get ns
# Key variables – SAS Viya on RACE
# The SAS Viya Ingress URL in this example points to https://gelenv.pdcesx1234.race.sas.com
current_namespace=gelenv
INGRESS_SUFFIX=$(hostname -f)
INGRESS_URL=https://${current_namespace}.${INGRESS_SUFFIX}
echo ${INGRESS_URL}
# Get certificates (TLS support)
export SSL_CERT_FILE=~/.certs/${current_namespace}_trustedcerts.pem
export REQUESTS_CA_BUNDLE=${SSL_CERT_FILE}
echo ${SSL_CERT_FILE}
# Confirm the sas-viya CLI folder
clidir=/opt/sas/viya/home/bin
cd $clidir
pwd
# Create a SAS Viya CLI profile
export SAS_CLI_PROFILE=${current_namespace}
./sas-viya --profile ${SAS_CLI_PROFILE} profile set-endpoint "${INGRESS_URL}"
./sas-viya --profile ${SAS_CLI_PROFILE} profile toggle-color off
./sas-viya --profile ${SAS_CLI_PROFILE} profile set-output fulljson
./sas-viya --profile ${SAS_CLI_PROFILE} profile show
SAS Viya CLI Login
Second, you need to login with your SAS credentials. This will allow you to get a SAS Viya access token and perform the operations required. My recommendation is to use the pyviyatools for authentication.
tee ~/.authinfo > /dev/null << EOF
default user sasadm password ******
EOF
chmod 600 ~/.authinfo
# Login and create a token
cd ~/admin/pyviyatools
./loginviauthinfo.py -f ~/.authinfo
The less elegant option is to directly employ the user and the password.
# Login and create a token
./sas-viya --profile ${SAS_CLI_PROFILE} auth login -user sasadm -password ******
Deploy to MAS
You must use the decisiongitdeploy plug-in to deploy the decision.
When you call the deploy command, you must be in the folder containing the decision files. This folder is where the Git repository was cloned locally.
In the example below, the gitDeploy folder contains two subfolders, one for each published rule set: autoAuction1_0 and autoAuctionMake1_0. The subfolder name is passed in the decisiongitdeploy command.
- Chapters
- descriptions off, selected
- captions settings, opens captions settings dialog
- captions off, selected
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
This is a modal window. This modal can be closed by pressing the Escape key or activating the close button.
The deployment code looks like:
# Deploy from GIT to MAS
# cd to the folder where the repository containing published was cloned
cd /shared/gelcontent/home/sasadm/gitDeploy
pwd
# Confirm the folder where sas-viya CLI is installed
ls /opt/sas/viya/home/bin/
# Deploy a decision from Git
/opt/sas/viya/home/bin/sas-viya --profile ${SAS_CLI_PROFILE} decisiongitdeploy deploy --force true --destinationtype=MAS autoAuction1_0
# Deploy another decision from Git
/opt/sas/viya/home/bin/sas-viya --profile ${SAS_CLI_PROFILE} decisiongitdeploy deploy --force true --destinationtype=MAS autoAuctionMake1_0
# Notes
## --destinationtype=MAS parameter is optional, as MAS is the default deployment destination
## --force true, allows to overwrite a MAS module if it already exists; results in an error if the module exists and the parameter is not specified
Conclusions
To deploy rule sets or decisions, from a Git repository, to a SAS Viya Micro Analytic Service (MAS) publishing destination:
- First, make the Git files accessible to the SAS Viya Command Line Interface (CLI).
- Second, select the existing publishing destination.
- Third, use the SAS Viya CLI decisiongitdeploy plug-in, to deploy to the chosen publishing destination.
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 the post content. If you wish to get more information, please write me an email.
Find more articles from SAS Global Enablement and Learning here.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
How to deploy SAS models from Git to MAS ?