sasctl.tasks#

Commonly used tasks in the analytics life cycle.

sasctl.tasks.get_project_kpis(project, server='cas-shared-default', caslib='ModelPerformanceData', filterColumn=None, filterValue=None)[source]#

Create a call to CAS to return the MM_STD_KPI table (Model Manager Standard KPI) generated when custom KPIs are uploaded or when a performance definition is executed on SAS Model Manager on SAS Viya 4.

Filtering options are available as additional arguments. The filtering is based on column name and column value. Currently, only exact matches are available when filtering by this method.

Parameters:
projectstr or dict

The name or id of the project, or a dictionary representation of the project.

serverstr, optional

SAS Viya 4 server where the MM_STD_KPI table exists, by default “cas-shared-default”

caslibstr, optional

SAS Viya 4 caslib where the MM_STD_KPI table exists, by default “ModelPerformanceData”

filterColumnstr, optional

Column name from the MM_STD_KPI table to be filtered, by default None

filterValuestr, optional

Column value to be filtered, by default None

Returns
——-
kpiTableDfDataFrame

A pandas DataFrame representing the MM_STD_KPI table. Note that SAS missing values are replaced with pandas valid missing values.

sasctl.tasks.register_model(model, name, project, repository=None, input=None, version=None, files=None, force=False, record_packages=True)[source]#

Register a model in the model repository.

Parameters:
modelswat.CASTable or sklearn.BaseEstimator

The model to register. If an instance of swat.CASTable the table is assumed to hold an ASTORE, which will be downloaded and used to construct the model to register. If a scikit-learn estimator, the model will be pickled and uploaded to the registry and score code will be generated for publishing the model to MAS.

namestr

Designated name for the model in the repository.

projectstr or dict

The name or id of the project, or a dictionary representation of the project.

repositorystr or dict, optional

The name or id of the repository, or a dictionary representation of the repository. If omitted, the default repository will be used.

inputDataFrame, type, list of type, or dict of str: type, optional

The expected type for each input value of the target function. Can be omitted if target function includes type hints. If a DataFrame is provided, the columns will be inspected to determine type information. If a single type is provided, all columns will be assumed to be that type, otherwise a list of column types or a dictionary of column_name: type may be provided.

version{‘new’, ‘latest’, int}, optional

Version number of the project in which the model should be created. Defaults to ‘new’.

fileslist

A list of dictionaries of the form {‘name’: filename, ‘file’: filecontent}. An optional ‘role’ key is supported for designating a file as score code, astore, etc.

forcebool, optional

Create dependencies such as projects and repositories if they do not already exist.

record_packagesbool, optional

Capture Python packages registered in the environment. Defaults to True. Ignored if model is not a Python object.

Returns:
modelRestObj

The newly registered model as an instance of RestObj

Notes

If the specified model is a CAS table the model data and metadata will be written to a temporary zip file and then imported using model_repository.import_model_from_zip.

If the specified model is from the Scikit-Learn package, the model will be created using model_repository.create_model and any additional files will be uploaded as content.

Changed in version v1.3: Create requirements.txt with installed packages.

Changed in version v1.4.5: Added record_packages parameter.

Changed in version v1.7.4: Update ASTORE handling for ease of use and removal of SAS Viya 4 score code errors