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.
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.
A series of posts have already discussed the publishing from SAS Viya to a Git repository:
The deployment process:
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.
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:
A Micro Analytic Service must exist prior to publishing. In most SAS Viya deployments, a MAS destination is created by default.
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.
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
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 ******
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.
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
To deploy rule sets or decisions, from a Git repository, to a SAS Viya Micro Analytic Service (MAS) 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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.