BookmarkSubscribeRSS Feed

Managing Connections to Data Sources and SAS Libraries for Compute Sessions in SAS Viya

Started ‎07-24-2022 by
Modified ‎07-24-2022 by
Views 4,149

New functionality in SAS Viya now allows administrators to define and manage Base SAS Libraries for the SAS Programming Run-Time engine. This is accomplished using SAS Studio to define Connection to a Library Data Source and SAS Environment Manager to manage the availability of the data source in Compute Contexts. In 2022.1.3 this new feature will support the migration of SAS 9 Base libraries to libraries in the Viya Programming runtime. In this first post, I will look at how you manage Connections to Data Sources in Viya. In a follow-up post, I will look at the migration of Base libraries from SAS 9 to libraries on the Compute server in SAS Viya.

 

How to Persist a Connection to a Base Library Data Source

 

In SAS Studio the “New Library Connection” dialog allows you to define a Library connection to a Base SAS library Data Source. What this does is make a SAS library available for a SAS session. The library is allocated based on the "metadata" in the Data Source Definition.

 

There are two ways to persist a library definition beyond the current SAS session.

 

They are shown in the screenshot below:

 

  • Assign and connect to data sources at startup
  • Allow all users to view the library connection

Let's look at what these options do.

 

gn-data-sources-01.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.

 

Assign and connect to data sources at startup

 

Firstly, individual users can Assign and connect to data sources at startup.

 

gn-data-sources-02.png

 

Selecting this option adds the LIBNAME statement to the SAS Studio autoexec file for all Contexts but only for this user. As you can see in the image below, the LIBNAME statement in the autoexec references the data source with the LIBDEF= options using the data sources URI. The LIBDEF= option on the LIBNAME retrieves pre-defined LIBNAME information from the Data Sources microservice and performs a LIBNAME assignment using that information.

 

SAS Help Center: LIBRARYDEFINITION= LIBNAME Statement Option

 

gn-data-sources-03.png

 

Allow all users to view the library connection

 

A Viya administrator(member of the SAS Administrators group) has additional options available that allow them to define a Connection to a Data Source that is available to all users of one or many compute contexts. This functionality is governed by selecting Allow all users to view the library connection.

 

gn-data-sources-04.png

 

If you choose:

 

  • connected makes the library available and connects to it for all users when a SAS Session using the current Context starts
  • disconnected makes the library available but DOES NOT connect to it for all users when a SAS Session using the current Context starts.

gn-data-sources-05.png

 

Disconnected libraries are useful for libraries that are used infrequently, they can save on server startup times.

 

There are some important details you should be aware of before you create Connections to a Base SAS library data source. To define a connection, you must have the following:

 

  • Path mounted to the Compute Server and in the allowlist
  • SAS Studio configured to allow access to the filesystem (showserverfiles)
  • SAS Studio configured so that the physical path is navigable under the custom path (filenavigationroot=CUSTOM) and path of library under fileNavigationCustomRootPath

 

To Configure SAS Studio in Environment Manager under Configuration > All Services select SAS Studio and edit sas.studio. SAS Studio Configuration Options are documented here. 

 

In SAS Studio the Allow all users to view the library connection option applies to each Context separately. Creating a Connection to a Data Source in SAS Studio also makes the resource available to all the Contexts in SAS Environment Manager. Let's look at how we can manage the connections in EV

 

SAS Administrators Manage Connections to Data Sources in SAS EV

 

For any of the Connections to Data Sources created in SAS Studio, an administrator can edit the properties of  a context to:

 

  • Add the library to the Context.
  • Assign the libraries automatically for all users when a SAS session using the Context starts (connected)
  • Make the libraries available for all users when a SAS session using the Context starts  (disconnected)
  • Keep the default LIBNAME or use a different LIBNAME for the Context

 

To access this functionality select Contexts in EV, edit the context, and in the dialog select Resources.

 

gn-data-sources-06.png

 

Security

 

The data source definitions do not reside in folders and are created with READ permissions for all authenticated users. Operating system permissions to the library physical paths are respected by the Compute server when the libref is assigned. This means that if a user cannot read the file-system directory they will not see the library in their SAS session.

 

Permissions on the definitions could be changed using the authorization plug-in of the sas-viya CLI. To do this you will need the URI of the data source. TIP: interactively the easiest way to find the URI is to select Assign and connect to data sources at startup and then view the URI in the autoexec. In batch, you can use your favorite REST client. Here I use callrestapi from the pyviyatools:

callrestapi.py -m get -e "/dataSources/providers/Compute/sourceDefinitions?filter=eq(name,'Financial Data')"

 

Libraries in the Compute Server Autoexec

 

Prior to the release of this new functionality an administrator had to add a libname statement to the autoexec of the Compute Server in SAS Environment Manager to have SAS libraries be made available to users on the startup of a SAS session. I covered how to do that in this post.

 

This functionality is still available. These libnames can be added using a traditional LIBNAME statement or a LIBNAME statement that references the data source definition. Libraries allocated in this way are assigned and connected for all SAS Compute sessions and may not be modified using the interface in SAS Studio.

 

Summary

 

Recent updates for SAS Environment Manager and SAS Studio make it easier for Viya administrators to manage the availability of Base SAS Libraries to Viya Compute Servers. In this post, I have described these changes and how you might use them. The two main takeaways are administrators can:

 

  • Create and Manage Connections to Data Sources in SAS Studio
  • Manage the availability of Connections to Data Source in SAS Environment Manager.

 

It is important to note that this is the first step in making it easier to manage libraries in Compute. The data source definition provides metadata around connections to libraries within Viya.  More work is planned in this area to provide some of the robust functionality we had in SAS 9.4 around management and authorization etc.

 

The availability of data source definitions that define the Base libraries has enabled, in 2022.1.3 the migration of Base SAS Libraries to Viya Compute libraries in support of migrated content that uses the Compute server (Studio Flows, Jobs, etc.). I will cover how the migration of SAS 9 libraries to Viya works in a follow-up post.

 

Many thanks to my colleagues Scott McCauley, Amy Peters, and Dave Mackie for their assistance with this post.

 

Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
‎07-24-2022 08:09 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