SAS Communities Library

We’re smarter together. Learn from this collection of community knowledge and add your expertise.
BookmarkSubscribeRSS Feed

How to Deploy SAS Decisions from Git to MAS

Started ‎03-14-2022 by
Modified ‎03-14-2022 by
Views 5,721

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.

 

bt_1_Deploy_Decisions_from_SAS_Intelligent_Decisioning_to_Git.png

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:

 

 

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.

 

bt_2_04_070_Publish_Git_05_01.mp4
Video Player is loading.
Current Time 0:00
Duration 0:00
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
    • Chapters
    • descriptions off, selected
    • captions off, selected
      (view in My Videos)

       

      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.

       

      bt_3_04_070_Publish_Git_05_03.mp4
      Video Player is loading.
      Current Time 0:00
      Duration 0:00
      Loaded: 0%
      Stream Type LIVE
      Remaining Time 0:00
       
      1x
        • Chapters
        • descriptions off, selected
        • captions off, selected
          (view in My Videos)

           

          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.

          Comments

          How to deploy SAS models from Git to MAS ?

          Version history
          Last update:
          ‎03-14-2022 08:09 PM
          Updated by:
          Contributors

          sas-innovate-white.png

          Join us for our biggest event of the year!

          Four days of inspiring keynotes, product reveals, hands-on learning opportunities, deep-dive demos, and peer-led breakouts. Don't miss out, May 6-9, in Orlando, Florida.

           

          View the full agenda.

          Register now!

          SAS AI and Machine Learning Courses

          The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

          Get started