BookmarkSubscribeRSS Feed

ESP 5.2 – Model Manager Integration

Started ‎06-07-2019 by
Modified ‎06-07-2019 by
Views 1,895

Integration between SAS ESP and SAS Model Manager has been available since the 4.3 release. This integration has been improved over the last two ESP versions (5.1 and 5.2). Let’s have a look at what this integration looks like in ESP 5.2 today.

 

First of all, you might want to check out my previous article to discover how the ESP-Model Manager integration fits in the global ESP Analytics picture.

 

Then, what is the ESP-Model Manager integration all about?

 

It’s about smoothly and seamlessly plugging analytical models managed in SAS Model Manager in a SAS ESP event flow in order to bring analytical capabilities to real-time event streams.

 

How does that work?

 

Starting point

You or the analytics team worked with SAS tools (SAS code or Visual Analytics/Statistics or Model Studio or…) to build analytical models to answer a particular business question. This process ended up in having a couple of models available in Model Manager so that they can be managed in a common model repository, evaluated for champion model selection, monitored for performance and published in any supported destination for production of scores.

 

nir_post35_01_modelmanager.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.

 

You have set a champion model. Then you are ready for bringing that analytical model to SAS ESP very easily for real-time scoring.

 

SAS ESP Studio Configuration

In ESP Studio, you can then import a SAS Model Manager champion model. You should have at least a source window that streams events from an input data source and the Model Manager import is located in the Analytics “Calculate” window.

 

In the “Calculate” window, you have to:

  • Define your output schema:
    • basically, you import the necessary fields from the parent window
    • they will be mapped by name match to the imported model input columns (if names are different, you have to rename the input names to match the model expected names using a Compute window for example)
  • Set the “Calculation” to “User-specified
  • Define a “Handler” for the specific connected parent window

nir_post35_02_espmodel.png

 

In the “Input Handler” configuration, select “Import a module from SAS Model Manager”:

 

nir_post35_03_importmodel.png

 

You then gain access to the model selection window:

 

nir_post35_04_modelmanagerrepository.png

 

This shows the SAS Model Manager Repository. Notice that you can only select a champion model. Also, the model must be of type dataStep or ds2Package or ds2MultiType:

  • dataStep means the scoring function has been designed as a DATA step code which will be converted into a DS2 package when moved to ESP
  • ds2Package means the scoring function has been designed as a DS2 package which will be moved as is to ESP
  • ds2MultiType means the scoring function is composed of an ASTORE file along with a DS2 wrapper

Here you can also check the input variables that the model expects as well as the output fields that the model will generate.

 

Moving forward, you can automatically add the model outputs to your ESP model by checking the “Add the output schema to the window”:

 

nir_post35_05_finalizeimport.png

 

As a result, if you go back on the “Input Handler” configuration, it appears now that the Model Manager import ended up in a MAS (Micro Analytic Service) module creation:

 

nir_post35_06_masmodule.png

 

To know what the MAS module looks like, open the MAS module configuration at the Project level:

 

nir_post35_07_masmoduledetails.png

 

The XML behind this configuration looks like this:

 

nir_post35_08_masmodulexml.png

 

Notice the MAS module XML definition that corresponds to the previous screenshot with a MAS Store reference.

 

Extract from the public documentation:

 

A SAS Micro Analytic Service store is a named, versioned object repository that is maintained by SAS Event Stream Processing. A store enables convenient access to DS2, C, Python, and ASTORE files in a SAS Micro Analytic Service module without requiring direct access to the ESP server’s file system. You can use the RESTful API to query, create, delete, and write objects to SAS Micro Analytic Service stores.

 

Also notice that the XML contains some metadata information about the model type and ASTORE file location.

 

At this point, nothing has been created on the ESP Server side. The MAS Store with the corresponding code and possibly the ASTORE file will be materialized (physically created on disk) at the first run using this metadata information.

 

When you start this ESP project, a couple of operations happen under the covers to import the required files onto the ESP Server and then the project can run:

 

nir_post35_09_modeltest.png

 

The dark side

When running the ESP project that contains a Model Manager imported model for the first time, the corresponding MAS Store is initialized.

 

A folder named with the Model Manager project UUID concatenated with another UUID is created under $DFESP_CONFIG/mas-modules (/opt/sas/viya/config/etc/SASEventStreamProcessingEngine/default/mas-modules) with the right versioned components, mainly a program and possibly an ASTORE file:

  • the “mas-modules” folder is not created by default right after the ESP installation and is created on the fly assuming the ESP user who is running the ESP server has the right permission to do so
  • the 0.1 version directory will contain the files

Sample folder structure:

 

nir_post35_10_masmoduletree.png

 

The _4MUYMBZ1WTY14YM8883CRZWT file actually represents the ASTORE file.

 

In order to proceed successfully with this initialization, the Viya environment requires to be setup appropriately as mentioned in the SAS Model Manager Administration documentation:

  • the location on the Compute Server host for ASTORE files created when a user sets a model as a Champion model in SAS Model Manager is /opt/sas/viya/config/data/modelsvr/astore
  • thus, this path on the Compute Server host MUST be accessible from the ESP Server host AND the ESP Studio host under a standardized path /models/astores/viya
    • either through an NFS mount (if remote)
    • or a symbolic link (if local)

New Champion Model

A good thing with the SAS Model Manager – ESP integration is that the ESP Studio user will be notified if there is a new champion model, so that the ESP model can be updated as soon as there is a change.

 

nir_post35_11_champion.png

 

The ESP Studio user can decide to update the MAS module corresponding to the Model Manager imported model to reflect the newest champion model. It is done at design time and doesn’t require any further post-configuration. Just clicking "Yes" updates it automatically.

 

Notice that it can be done at run time, without stopping your ESP project, when you use Event Stream Manager to deploy your ESP projects to ESP servers.

 

Benefits of using SAS Model Manager for ASTORE-based models (vs using ASTORE-based models in Model Reader/Score windows)

Designing models in SAS Model Studio (before managing them in SAS Model Manager) requires sometimes some data preparation tasks (aka data mining preprocessing) such as imputation, binning, replacement, etc. When the model designed is ASTORE-based (gradient boosting, forest, etc.), this data preparation phase is not part of the ASTORE file, but rather is available alongside as a DS2 code.

 

SAS Model Manager deploys the ASTORE file + the data preparation DS2 code as a single unit in ESP Studio (hence the "multi-type" model).

 

In contrast, ASTORE-based models deployed with the Model Reader/Score windows might require the data preparation tasks to be implemented in the upstream windows, which could be tedious to do.

 

So Model Manager integration of ASTORE-based models offers a great advantage over the Model Reader/Score approach.

 

Limitation

The current SAS Model Manager – ESP integration is limited to one single Viya instance. In other words, you cannot import a SAS Model Manager analytical model configured in one Viya instance into ESP Studio configured in another Viya instance. They have to be part of the same Viya deployment to allow this communication.

 

Thanks for reading.

Comments

Hi,

Thank you for explaining in detail the integration between ESP and MM. Is there any update in the architecture of ESP in the new version of using multiple SAS Viya instance with ESP Studio.

Regards,

Muhammad Haseeb

 

Hi Muhammad,

 

As far as I know, the integration between ESP Studio and Model Manager is still limited to one single Viya instance. ESP Studio is able to access Model Manager's repository on the same Viya instance.

 

Regards,

Nicolas.

Version history
Last update:
‎06-07-2019 03:53 AM
Updated by:
Contributors

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