SAS Viya REST Client
Project description
Full documentation: https://sassoftware.github.io/python-sasctl
Overview
The sasctl package enables easy communication between the SAS Viya platform and a Python runtime. It can be used as a module or as a command line interface.
sasctl.folders.list_folders()
sasctl folders list
Prerequisites
sasctl requires the following Python packages be installed. If not already present, these packages will be downloaded and installed automatically.
- requests
- six
The following additional packages are recommended for full functionality:
- swat
- kerberos
Installation
pip install sasctl
Functionality that depends on additional packages can be installed using the following:
pip install sasctl[swat]
pip install sasctl[kerberos]
pip install sasctl[all]
Getting Started
Once the sasctl package has been installed and you have a SAS Viya server to connect to, the first step is to establish a session:
>>> from sasctl import Session
>>> with Session(host, username, password):
... pass # do something
sasctl --help
Once a session has been created, all commands target that environment. The easiest way to use sasctl is often to use a pre-defined task, which can handle all necessary communication with the SAS Viya server:
>>> from sasctl import Session, register_model
>>> from sklearn import linear_model as lm
>>> with Session('example.com', authinfo=<authinfo file>):
... model = lm.LogisticRegression()
... register_model(model, 'Sklearn Model', 'My Project')
A slightly more low-level way to interact with the environment is to use the service methods directly:
>>> from pprint import pprint
>>> from sasctl import Session
>>> from sasctl.services import folders
>>> with Session(host, username, password):
... folders = folders.list_folders()
... pprint(folders)
{'links': [{'href': '/folders/folders',
'method': 'GET',
'rel': 'folders',
'type': 'application/vnd.sas.collection',
'uri': '/folders/folders'},
{'href': '/folders/folders',
'method': 'POST',
'rel': 'createFolder',
... # truncated for clarity
'rel': 'createSubfolder',
'type': 'application/vnd.sas.content.folder',
'uri': '/folders/folders?parentFolderUri=/folders/folders/{parentId}'}],
'version': 1}
The most basic way to interact with the server is simply to call REST functions directly, though in general, this is not recommended.
>>> from pprint import pprint
>>> from sasctl import Session, get
>>> with Session(host, username, password):
... folders = get('/folders')
... pprint(folders)
{'links': [{'href': '/folders/folders',
'method': 'GET',
'rel': 'folders',
'type': 'application/vnd.sas.collection',
'uri': '/folders/folders'},
{'href': '/folders/folders',
'method': 'POST',
'rel': 'createFolder',
... # truncated for clarity
'rel': 'createSubfolder',
'type': 'application/vnd.sas.content.folder',
'uri': '/folders/folders?parentFolderUri=/folders/folders/{parentId}'}],
'version': 1}
Examples
A few simple examples of common scenarios are listed below. For more complete examples see the examples folder.
Show models currently in Model Manager:
>>> from sasctl import Session
>>> from sasctl.services import model_repository
>>> with Session(host, username, password):
... models = model_repository.list_models()
Register a pure Python model in Model Manager:
>>> from sasctl import Session, register_model
>>> from sklearn import linear_model as lm
>>> with Session(host, authinfo=<authinfo file>):
... model = lm.LogisticRegression()
... register_model(model, 'Sklearn Model', 'My Project')
Register a CAS model in Model Manager:
>>> import swat
>>> from sasctl import Session
>>> from sasctl.tasks import register_model
>>> s = swat.CAS(host, authinfo=<authinfo file>)
>>> astore = s.CASTable('some_astore')
>>> with Session(s):
... register_model('SAS Model', astore, 'My Project')
Contributing
We welcome contributions!
Please read CONTRIBUTING.md for details on how to submit contributions to this project.
License
See the LICENSE file for details.
Additional Resources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sasctl-1.4.2.tar.gz
.
File metadata
- Download URL: sasctl-1.4.2.tar.gz
- Upload date:
- Size: 69.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6416b98c04fdaae2fb64ce32ab513edc452e6ff213bdff95200124d8f8753f9f |
|
MD5 | db8c80c423433ae07ec447a9eacae19c |
|
BLAKE2b-256 | 7a03568827897d84261e15319af9c85a55906c0b15899f821b2bb1b940e4bc77 |
File details
Details for the file sasctl-1.4.2-py3-none-any.whl
.
File metadata
- Download URL: sasctl-1.4.2-py3-none-any.whl
- Upload date:
- Size: 89.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b47ba387cbc11b6607286a1d58fd8fd9814af96bf289b19a7cdfabf94a9deef0 |
|
MD5 | a304c0fa9b608a1393baaf59db33f9d7 |
|
BLAKE2b-256 | 629303d177d86354e0b176dcaee66faabbb906be18452e6127a7b3d77ee4688c |