BookmarkSubscribeRSS Feed

How to Publish a Decision to Azure with SAS Container Runtime

Started ‎09-22-2021 by
Modified ‎10-31-2021 by
Views 5,323

SAS Container Runtime (SCR) allows you to publish a decision or rule set developed with SAS Intelligent Decisioning as a container image in Azure. The stable SAS Viya version 2021.1.4 adds SCR (SCR, pronounced “soccer”) support for decisions and rule sets, in addition to SAS models. This post details the steps to publish a SAS decision or rule set as an Azure container image and validate the publishing. Scoring the decisions will be covered in separate posts.

The Big Picture

Watch the following short video to understand the end result.

 

Caveats

Firstly, the type of decisions you can publish today:

  • Assignment rule sets (can use lookup tables, custom functions, and global variables).
  • Treatment groups.
  • SAS models: analytic store, DATA step, DS2 multi-type or DS2 package.
  • Sub-decisions.
  • DS2 code files that do not contain SQL queries.
  • Filtering rule set nodes

Read more about it in SAS Intelligent Decisioning | 2021.1.4.

The Steps

The steps to publish SAS decisions or rule sets are the following.

  • SAS Viya Deployment
  • Azure Components
  • SAS Viya Components
  • Decision or rule set publishing
  • Publishing validation

The first three steps are exactly the same in How to Publish a SAS Model to Azure with SCR: A Start-to-Finish Guide and won't be repeated here. This post will focus only on decision or rule set publishing and publishing validation .

 

Decision or rule set publishing

To publish to Azure, you need at least a rule set to begin with:

  1. Define a rule set. This rule helps a fleet manager decide if to bid or not for cars auctioned online. The output is a binary Bid decision (0 or 1), depending on the car characteristics and valuation data.

     

    310-SAS-Intelligent-Decisioning-rule-set-1024x487.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.
  2. Test the rule set.
  3. If you decide to use lookup tables in the rule set, they are supported by SCR. Lookup tables are used in the autoAuctionMake rule set (see image below).
  4. Create a decision which refines the logic. It incorporates the rule above on a decision branch and adds several elements. The output is the binary Bid decision (0 or 1), plus a callOffice indicator and a bidCommand.

     

    320-SAS-Intelligent-Decisioning-decision-1024x487.png
  5. Test the decision.

 

Decision or Rule Set Publishing

You only need to configure the Azure publishing destination once. SAS Model Manager and SAS Intelligent Decisioning are sharing the destination.

With the Azure publishing destination now defined:

 

To publish the decision to Azure is very easy.

 

330-Publish-SAS-Intelligent-Decisioning-decision-to-Azure-Container-Registry-1024x487.png

 

 

What happens during publishing? Switch to the Azure portal, in the SAS Viya Azure Kubernetes Service (AKS) cluster. AKS cluster > Workloads > Pods > sorted by Age descending, you will see several pods spawned:

 

340-SAS-Viya-Pods-on-Azure-Kubernetes-Service-Cluster-1024x517.png

 

At some point during publishing you would see a kaniko pod. Kaniko is a tool to build container images from a Dockerfile, inside a container or Kubernetes cluster. Kaniko is used by SCR.

 

350-Kaniko-Pod-on-Azure-Kubernetes-Service-Cluster-1024x330.png

 

After publishing is successful, you will see your SCR image in the Azure Container Registry, under Repositories.

 

360-SAS-Intelligent-Decisioning-decision-published-to-Azure-Container-Registry-1024x487.png

 

 

720 SAS Container Runtime decision image published to Azure Container Registry.png

 

 

Decision Publishing Validation

To validate your publishing destination, select the decision, go to Scoring > Publishing Validation, select an input table and run the validation.

 

370-SAS-decision-Azure-publishing-validation-1024x249.png

 

During the publishing validation, switch to the Azure Kubernetes Service (AKS) cluster. From AKS cluster > Workloads > Pods > sort by Age descending, and you will see a similar list:

 

380-SAS-Viya-Pods-on-Azure-Kubernetes-Service-Cluster-Scoring-1024x485.png

 

 

The scoring pod is where the publishing validation happens and where the decision is tested against input data.

 

When you open the pod events, you can see the scoring pod:

  • Pulling the decision SAS Container Runtime image autoauctiondec1_0:latest, from the Azure Container Registry sascontainers.azurecr.io, where it was published earlier.
  • Starting a container for the decision scoring process.

 

730 SAS Viya Scoring Pods on Azure Kubernetes Service Cluster.png

 

The pod will run for a while. This is normal. When the pod is terminated, publishing validation will complete. Back in SAS Intelligent Decisioning, click on Results:

 

390-SAS-decision-Azure-publishing-validation-successful-1024x487.png

 

Output

The output shows the Bid values, just like when you test the decision in SAS.

 

392-SAS-decision-Azure-publishing-validation-output-1024x487.png

 

Code

The code section will reveal python code, passing commands to the AKS cluster to create a deployment, a service. It seems to be very helpful if you want to debug and run the code step by step.

 

740 SAS decision Azure publishing validation code.png

 

Log

The log provides a few metrics: the process to create the container takes about 5 minutes. While it might seem a bit long, the time is very similar to the creation of an Azure Container instance.

 

396-SAS-decision-Azure-publishing-validation-log-1-1024x479.png

 

 

Notice the container endpoint. It runs on a port in the 30000-32767 range. The IP is a private Azure IP, known within the Kubernetes Service resource group virtual network.

Rule Sets

The publishing and validation mechanism for rule sets is exactly the same as for decisions.

Conclusions

In this post, you learnt how to publish SAS Intelligent Decisioning rule sets and decisions to Azure and how to validate their publishing.

Note that once the SCR images are in Azure, there is zero dependency on SAS Viya for decision scoring. Azure takes over. To change the decision and publish a new version, yes, you will still require SAS Viya.

You can deploy your container image in a number of ways and score the decisions or the rule sets. Read more about it in future posts.

 

Want to Know More?

Thank you for your time reading this post. If you found it useful, like it. Please comment and tell us what you think about the new SCR and Azure publishing destination.

Version history
Last update:
‎10-31-2021 09:23 PM
Updated by:

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started